The factorial of a number using recursion in Python!#shorts #coding #python #learnpython

preview_player
Показать описание
The factorial of a number using recursion in Python!

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

while True:
num = int(input("Enter the number: "))
print(factorial(num))

Recursion means a function calling itself to solve smaller subproblems.

Subscribe for daily Python Shorts @codewithme03

#Python #Recursion #Factorial #PythonShorts #LearnPython
Рекомендации по теме
visit shbcf.ru