Advertisement
meteor4o

Java-Factorial_BigInteger

Jul 5th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.math.BigInteger;
  3.  
  4. public class Main {
  5.  
  6.  
  7. public static void main(String[] args) {
  8. Scanner sc = new Scanner(System.in);
  9.  
  10. int n = Integer.parseInt(sc.nextLine());
  11. BigInteger sum = new BigInteger(String.valueOf(1));
  12.  
  13. for(int i = 1; i<= n; i++) {
  14.   sum = sum.multiply(BigInteger.valueOf(i));
  15. }
  16.  
  17.  
  18. System.out.println(sum);
  19.  
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement