Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Factory {
- public static void main(String[] args) {
- Scanner myScanner = new Scanner(System.in);
- //Set variables
- int usernumber = myScanner.nextInt();
- int loop = usernumber;
- int finalAnswer = usernumber;
- int multiply = 1;
- //Ask the user for a number between 1 and 20
- System.out.println("Please enter a number between 1 and 20(inclucive)");
- //Here we loop round and round we go....
- while(--loop > 0) {
- finalAnswer = finalAnswer * multiply++;
- System.out.println(finalAnswer);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment