Recursion in Python Tutorial


What is Recursion?



A function is said to be a Recursive when it calls itself.

Recursion is a way of programming, in which a function calls itself one or more times in its body. Usually, it  returns value to the function.In Python, a function can call other functions and It is also possible for the function to call itself.


Example :-  Find the factorial of an integer using Recursion


def factorial(number):
      if number==1:
                 return 1
   
      return (number * factorial(number-1))
   
print(factorial(6))

o/p:- 720

Explanation:-






Comments