import java.io.*;
class simple_factorial_given_number
{
public static void main(String args[])
{
int n,no,f=1;
try
{
DataInputStream cin=new DataInputStream(System.in);
System.out.println("enter any number");
n=Integer.parseInt(cin.readLine());
no=n;
while(n>0)
{
f=f*n;
n--;
}
System.out.println("factorial of "+no+" is = "+f);
}
catch(Exception e)
{
System.out.println("Wrong data");
}
}
}
No comments:
Post a Comment