Program to find factorial of given number in java programming

Program to find factorial of given number in java programming :
import java.lang.*;
import java.io.*;
import java.util.*;
class FactDemo
{
public static void main(String a3pro[])
{
int num,i,fact=1;
Scanner s=new Scanner(System.in);
System.out.println("a3programming.blogspot.com");
System.out.println("Enter number to find factorial :");
num=s.nextInt();
for(i=1; i<=num; i++)
{
fact=fact*i;
}
System.out.println("Result :"+fact);

}
}
Expected output:

Post a Comment

2 Comments