galinyotsev123

ProgBasicsJavaBook7.1ComplexLoop08factorial

Jan 14th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E08factorial {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. int fact = 1;
  9.  
  10. do {
  11. fact = fact * n;
  12. n--;
  13. } while (n > 1);
  14. System.out.println(fact);
  15.  
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment