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