Advertisement
cyecize

factorial-che

May 4th, 2022
763
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public static void main(String[] args) {
  2.         Scanner input = new Scanner(System.in);
  3.  
  4.         int number;
  5.         do {
  6.             number = input.nextInt();
  7.             if (number == 0) {
  8.                 continue;
  9.             }
  10.  
  11.             int sum = 1;
  12.             int count = 1;
  13.             while (count <= number) {
  14.                 sum *= count;
  15.                 count++;
  16.             }
  17.  
  18.             System.out.println(sum);
  19.         } while (number != 0);
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement