Simple and Comprehensive Java Programs
Labels
Armstrong
(1)
Array
(1)
Celsius to Fahrenheit
(1)
Commandline
(4)
even odd
(1)
Factorial
(1)
Fibonacci
(1)
Hello World
(1)
Java.Lang.Math
(1)
java.util.Arrays
(1)
Java.Util.Scanner
(3)
Reverse of number
(1)
Rhombus
(1)
Square Root
(1)
Table
(1)
Showing posts with label
Factorial
.
Show all posts
Showing posts with label
Factorial
.
Show all posts
Wednesday, 11 September 2013
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:
Older Posts
Home
Subscribe to:
Posts (Atom)