Published on January 26, 2024By DeveloperBreeze
public static long factorial(int n) {
if (n == 0 || n == 1) {
return 1;
}
return n * factorial(n - 1);
}
int number = 5;
long result = factorial(number);
System.out.println("Factorial of " + number + " is " + result);
Comments
Please log in to leave a comment.