Custom Search

Saturday, 25 August 2012

Java Program to find Factorial, Write a Java Program for an application to find factorial


Java Program to find Factorial, Write a Java Program for an application to find factorial


Program:-
class factorial
{
public static void main(String args[])
{
int no;
no = Integer.parseInt(args[0]);
Logic L=new Logic();
L.fact(no);
}
}
class Logic
{
public void fact(int n)
{
int f,no;
no = n;
f=1;
while(no>0)
{
f = f * no;
no = no - 1;
}
System.out.println("Factorial of " + n + " is " + f);
}
}

No comments:

Post a Comment

Laptops