I am trying to write a Java program to calculate factorial of a large number. It seems BigInteger is not able to hold such a large number.
BigInteger
The below is
Try this instead, an iterative algorithm:
public static BigInteger getFactorial(int num) { BigInteger fact = BigInteger.valueOf(1); for (int i = 1; i <= num; i++) fact = fact.multiply(BigInteger.valueOf(i)); return fact; }