
I want to practise with Java Recursive program

The recursive functions are the function which repeats itself in a java program. Here is an example of recursive function that finds the factorial of a number.
public class FactorialExample{
public static long factorial(int n){
if(n <= 1)
return 1;
else
return n * factorial(n - 1);
}
public static void main(String [] args){
int num=5;
System.out.println(factorial(num));
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.