Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class Factorial {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- int n;
- System.out.println("Enter a number: ");
- n = in.nextInt();
- int factorial = n;
- for (int i = 1; i < n; i++)
- {
- n = n - 1;
- factorial = factorial * n;
- }
- System.out.printf("Your number's factorial is %d", factorial);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement