import
java.util.Scanner;
public class Factorial {
public static void main(String[]
args) {
System.out.println("Enter
the number");
Scanner
scan = new Scanner(System.in);
int number =
scan.nextInt();
int factorial =
number;
for (int i = 1; i <
number; i++) {
factorial
= factorial * i;
}
System.out.println("Factorial
of a "+number+" is"+" "+ factorial);
}
}
Output:
Enter
the number
5
Factorial
of a 5 is 120
No comments:
Post a Comment