Java – Recursion

Java – Recursion 2017-06-13T00:01:45+00:00

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.

EX :


 


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