137. JAVA Program to Calculate Factorial of a number using static.
How does this program work?
- This program is used to find the factorial of a given number using java.
- Factorial number is defined by the product of all the digits of given number.
- Factorial of 0 is always 1.
Here is the code
//To find the Factorial of a given number using static
public class static{
public static void main(String args[] )
{
int i,fact=1;
//It is the number to calculate factorial
int number=5;for (i=1;i<=number;i++)
{
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
}