6 – Best python program to find factorial using recursion

Python program to find factorial using recursion

Factorial is multiplying number by every number below it till 1.

Recursion : “The repeated application of a recursive procedure or definition.” – Oxford Languages
In programming we have recursion functions, these functions are the functions which call themselves in the same function.
In simple words if any function calls itself then it is known as recursion.

Logic to find factorial using recursion​ in python

`"""Author : ITVoyagers (https://itvoyagers.in)Date :22nd December 2020Description : Python program to find the factorial of a number using recursion."""def recur_facto(n):"""Function to return the factorialof a number using recursion"""    if n == 1:        return n    else:        return n*recur_facto(n-1)num = int(input("Enter a number: "))# check is the number is negativeif num < 0:    print("Sorry, factorial does not exist for negative numbers")elif num == 0:    print("The factorial of 0 is 1")else:    print("The factorial of",num,"is",recur_facto(num))`

Output :

Enter a number:
5
The factorial of 5 is 120