Advertisement
veronikaaa86

03. Big Factorial

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