There are two cases :
# Example 1:
def fun(n):
if(n == 0):
return
print(n)
fun(n-1)
fun(5)
# Example 2:
def fun(n):
if(n == 0):
return
fun(n-1)
print(n)
fun(5)
In Example-1 the print statement will execute first then the fun(n-1) will run...
Showing posts with label Recursion. Show all posts
Showing posts with label Recursion. Show all posts