examples of recursion methods in python

0

a recursive function is a function that call it self for several times.

 

recursion is another way of making loops.

All Contributions

this is an example of infinite loop using recursion function:

#define the function:
def h():
    print('hello')
    h()


#call the function:
h()

python program to implement recursion for factorial of a number, that demonstrates a user-defined function and return a statement using functions

---------------

def factorial(n):
    if n==1:
        return 1
    else:
        return n*factorial(n-1)

print(factorial(5))

total contributions (2)

New to examplegeek.com?

Join us