factorial number program in java
Answers
Answered by
3
import java.io.*;
class factorial
{
public static void main(String args[])
{
DataInputStream in= new DataInputStream(System.in);
int n,i,f=1;
try
{
System.out.print("Enter any number:");
n=Integer.parseInt(in.readLine());
for(i=1;i<=n;i++)
{
f=f*i;
}
System.out.println("Factorial of the number:"+f);
}
catch(Exception e)
{};
}
}
Similar questions