Java Program to Find Factorial of a Number
In this example, we are giving a program to find a factorial of a number.
To find a factorial of a number:
# To find a factorial of a numberpublic classFactorial {public static void main(String[] args) {int num = 10;long factorial = 1;for(int i = 1; i <= num; ++i) {factorial *= i;}System.out.printf("Factorial of %d = %d", num, factorial);}}
Output:
Factorial of 7 = 5040