Java Program to find factorial of a given number through Commandline
class Factorial
{
public static void main(String ar[])
{
int n=Integer.parseInt(ar[0]);
int f=0;
fact(n);
}
static void fact(int n1)
{
int f=1;
for(int i=1;i<=n1;i++)
{
f=f*i;
}
System.out.println("Factrorial is = "+f);
}
}
Output:
No comments:
Post a Comment