What is the factorial in java

The factorial of a positive integer is the product of all positive integers less than it and itself.need to note that the factorial of 0 is 1.we use n! to represent the factorial of an integer number n.
In other words,n!=1x2x3x4x...xn.also can use recursion to defined a factorial as 0!=1, n!=(n-1)!xn.
factorial program in java

factorial using recursion in java

Let's write a java simple recursion program to get the factorial of given numbes from 0 to 10:

output

factorial using loop in java

output

Categories: Java