Pages
Home
Interview Question
Tricks
Latest Updates
Our Website
Contact Us
Wednesday, May 23, 2012
Factorial (JAVA)
class Factorial
{
public static void main(String arg[])
{
if (arg.length!=1)
System.out.print("Invalid");
else
{
int n=Integer.parseInt(arg[0]);
int fact=1;
while(n>0)
{
fact=fact * n;
n--;
}
System.out.print("Factorial="+fact);
}
}
}
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment