martinvalchev

Factorial

Nov 21st, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.35 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.         int n = Integer.parseInt(scanner.nextLine());
  7.         int result = 1;
  8.  
  9.        while (n > 0){
  10.             result *= n;
  11.             n--;
  12.         }
  13.         System.out.println(result);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment