Factorial of Large Numbers C Program

By | September 10, 2016

C Program To Find Factorial of Large Numbers using Arrays

Learn How to Find Factorial of Large Numbers in C Programming Language. This C code uses Arrays to store Intermediate results while calculating factorial of a Big Number. A factorial is the product of an Integer with all the Integers less than it till 1, considering the number is Positive.

There are some restrictions in the normal method to Calculate Factorial of an Integer in C ProgrammingFor normal Integers like 5, 10, 20, factorial can be found out easily but if you try to find out factorial of 100 or greater numbers, this code won’t show you the correct output.

It is because the range of factorial of 100 is quite larger than the range of an integer datatype. Therefore, we shall use Array data structure to store the Intermediate results of calculating factorial of a given Big Integer.

Algorithm to Calculate Factorial of a Large Number

  • Create an Array variable with a large Dimension such as 400 or 500 so that if the Factorial result is 500 Numbers long, we will be able to display it in the output efficiently.
  • Initialize the Array variable with 1 and initialize a limit variable with 1 too.
  • Perform the following calculation from a = 2 to Number
    • Multiply a with array variable and update the Limit and Array variable simultaneously.

Example

120

6689502913449127057588118054090372586752746333138029810295671352301633557244962989366874165271984981308157637893214090552534408589408121859898481114389650005964960521256960000000000000000000000000000

 

Must Read: C Program To Print Map of India

 

C Program To Find Factorial of Large Numbers using Arrays

Output

Find Factorial of Large Numbers in C Programming using Arrays for Big Integers

If you have any compilation errors or doubts in this C Program To Calculate Factorial of Big Numbers, let us know about in the Comment Section below. Find more information about the Factorial of a Number in this Wikipedia article.

4 thoughts on “Factorial of Large Numbers C Program

  1. Sneha Mishra

    Wow! I had not thought about such a concept. Thanks for posting this Factorial of Large Number code.

    Reply
  2. Vinay Pathak

    Thanks for the algorithm of factorial of a large number i needed this more than the c program.

    Reply
  3. Vishwajeet Singh

    I dont think there is any other datatype for storing such a large number, Isn’t it?

    Reply

Let's Discuss