import java.util.*;
class ranjan1
{
public static void main(String arts[])
{
int n,m;
long f=1;
Scanner rd=new Scanner(System.in);
System.out.print("Enter any number:");
n=m=rd.nextInt();
if(n<0)
{
System.out.println("Factorial of negative number cannot be determined.");
}
else
{
while(n>0)
{
f=f*n;
n--;
}
System.out.println("Factorial of "+m+" is = "+f);
}
}
}
Output
Enter any number : 5Factorial of 5 is = 120
0 Comments