Factorial.java 497B

123456789101112131415161718192021222324252627
  1. import java.math.BigInteger;
  2. //Write a program that computes the factorial n! = 1 x 2 x ... x n,
  3. //using BigInteger. Compute the factorial of 1000.
  4. public class Factorial {
  5. public BigInteger factorialOf(Integer value){
  6. int i = 1;
  7. int j = 1;
  8. for(i = 1; i <= value; i++){
  9. j=j*i;
  10. }
  11. //j is the factorial of value
  12. BigInteger x = BigInteger.valueOf(j);
  13. return x;
  14. }
  15. }