5-3 Factorial
Post date: Apr 3, 2014 10:06:14 AM
/*Write a function to calculate the factorial value of any integer
Call this function from main( ) and print the results in a function.*/
package factorial;
import java.util.Scanner;
public class Factorial
{
public static void main(String[] args)
{
Fact();
}
public static void Fact()
{
Scanner S=new Scanner(System.in);
System.out.print("Enter a number : ");
int n=S.nextInt(),f=1;
for (int i=n; i>1; i--)
f*=i;
System.out.println("Factorial of "+n+"="+f);
}
}