Professional Documents
Culture Documents
returntype methodname(){
//code to be executed
methodname();//calling same method
}
public class RecursionExample {
static int factorial(int n){
if (n == 1)
return 1;
else
return(n * factorial(n-1));
}
}
}
• Output:
• Factorial of 5 is: 120