# Factorial of a Number using Recursion in Python

Problem: Write a python program to find factorial of a number using recursion.

Solution: This python program accepts a number from user, passes it to a function named `factorial_using_recursion()` which checks whether given number is equal to 1, if yes then the Factorial of given number is 1 and program stops else this function calls itself with `number - 1` as parameter to the function. Like wise this process continues until given number passed to the function is 1 and finally factorial of given number is returned to the calling function i.e. `main()` function.

To understand the concept of recursion better please read Recursion in C.

## Factorial of a number in python

Here is the source code to find factorial using recursion in python
``````def factorial_using_recursion(num): if num == 1: return num else: return num*factorial_using_recursion(num-1) number = int(input("Enter any number: "))if number < 0: print("Negative numbers dont have factorial")elif number == 0: print("Factorial of 0 is 1")else: print("The factorial of", number, "is", factorial_using_recursion(number))
``````

### Output:

```Enter any number: 5
The factorial of 5 is 120```