Java – Recursion

Java – Recursion 2017-08-09T11:23:59+00:00

Java Recursion :

Recursion is the process of defining something in terms of itself. When function call it self is called recursion. A method that calls itself is said to be recursive.

JAVA – RECURSION EXAMPLE PROGRAM :


 


Output :
Enter int no = 7
Factorial of7 is 5040
Here the method fact is recursive because it calls itself.
The whole precess something like this
result = fact(7-1) * 7 and so on until it returns 1.
So one thing is sure that we have to take care that in every recursive process there must be a terminate condition to come out from recursion.

Prev Next