Factorial.java 535B

123456789101112131415161718192021222324
  1. import java.util.Scanner;
  2. import java.math.BigInteger;
  3. public class Factorial {
  4. public BigInteger factorialOf(Integer value){
  5. Scanner scanner = new Scanner(System.in);
  6. System.out.println("Enter a number: ");
  7. int userInput = scanner.nextInt();
  8. int counter = userInput;
  9. BigInteger result = BigInteger.ONE;
  10. for(int i=1; i <counter; i++){
  11. value = value*i;
  12. }
  13. System.out.println(value);
  14. return result.multiply(BigInteger.valueOf(value));
  15. }
  16. }