Home >>Java Programs >Factorial Program using loop in java
In this example, we will see a Java program through which we can find the factorial of any given input number.
Factorial of any number "n" is the product of all the positive descending integers. Factorial of n is denoted by n!.
In this program, we will use a loop to find the factorial of the given number. The loop will iterate the given input number (n) of times.
Program
class Main
{
public static void main(String args[])
{
int i,fact=1;
int number=14;//It is the number to calculate factorial
for(i=1;i<=number;i++){
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
}