Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FactorialToTwenty {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- long factorial = 1;
- for(factorial = 1; factorial < 20; factorial++)
- {
- System.out.print("n = ");
- int n = input.nextInt();
- do {
- factorial *= n;
- n--;
- }
- while (n > 0);
- System.out.println("n! = " + factorial);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement