Factorial of Large Number in Java

It is not possible to store factorial for large number like 50 into inbuilt data types like integer or long. Because factorial of 50 has almost 60 digits. Imagine how we can store it in int or long. We can find factorial of such numbers using BigInteger class defined in java.math package. 

Below program shows how you can do this.

Also Read: Factorial of Large Number in C and C++

Program for Factorial of Large Number in Java



Factorial of Large Number in Java

Comment below if you are facing any difficulty to understand this program.

4 thoughts on “Factorial of Large Number in Java

  1. Anuradha Desai

    Why have you used 1 in in the line 6
    BigInteger fac = new bigInteger(“1”)
    Please explain


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.