Advertisement
Dido09

Factorial

Feb 13th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Factorial {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int num = Integer.parseInt(scanner.nextLine());
  8. long factorial = 1;
  9. for(int i = 1; i <= num; ++i)
  10. {
  11. factorial = factorial * i;
  12.  
  13. }
  14. System.out.printf(String.valueOf(factorial));
  15.  
  16. }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement