➽ Program:-
import java.util.*;
class Main
{
public static void
main(String args[])
{
int i,
num, fact=1;
Scanner
sc = new Scanner(System.in);
System.out.print("Enter a Number: ");
num =
sc.nextInt();
for(i=1;
i<=num; i++)
{
fact = fact * i;
}
System.out.println("Factorial of " + num + " is " + fact);
}
}
➽ Output:-
Enter a Number: 8
Factorial of 8 is 40320
0 Comments
Please do not enter any spam link in the comment section.