# Calculating Factorial of large numbers in c

As we all know there is memory limitation in C. If we want to store number which is more than of 4 byte we cannot use int data type. We can use long data type to store value which is upto 8 byte. What after that?. If our value is of more than 8 bytes then we have to implement our own method to store value.

Here is the implementation of calculating factorial for large numbers like 100!

Explanation:

This program works on basic method of multiplication of a two numbers.

1234

X 15

Ans: 18510

Steps are:

Step                                       Digit                       Carry

15*4 = 60;                            0                              6

(15*3)+6=51                       1                              5

(15*2)+5=35                       5                              3

(15*1)+3=18                       8                              1

After this carry digits are extracted and stored in array.  ( if our carry was 25 then we must extract 2 and 5 then store it in array )

So output is: 18510

In program:

Array of 200 lengths is taken to store digits of multiplication result.

Index variable indicates the length of output..

tmp is used to store carry value;

————————————————————————————————————————–

Calculating Factorial of large numbers in c

Her we have taken array size of 200 so we can calculate factorial of a number whose digits are 200. if you want to calculate for more than 200 just increase the size of array.

# C program to print pascal triangle

Pascal’s Triangle : Pascal’s triangle is a triangular array of the binomial coefficients.