import java.math.BigInteger; public class Factorial { public BigInteger factorialOf(Integer value){ BigInteger factorialValue = BigInteger.valueOf(1); for (int i=1;i<=value;i++) { factorialValue = factorialValue.multiply(BigInteger.valueOf(i)); } return factorialValue; } /* Overflow public String factorialOf1000(){ int value = 1000; BigInteger factorialValue = new BigInteger("1"); for (int i=1;i<=value;i++) { factorialValue = factorialValue.multiply(new BigInteger(i + "")); } return factorialValue.toString(); } */ }