programming-examples/java/Basics/Factorial (Java).java

13 lines
333 B
Java
Raw Normal View History

2019-11-18 14:44:36 +01:00
class FactorialExample
{
public static void main(String args[])
{
int i,fact=1;
int number=5;//It is the number to calculate factorial
for(i=1; i<=number; i++)
{
fact=fact*i;
}
System.out.println("Factorial of "+number+" is: "+fact);
}
}