Below is the Python program to find factorial of a number.
# Python program to find the factorial of a number using recursion def factorial(n): """Function""" if n == 1: return n else: return n*factorial(n-1) num = int(input("Enter a number: ")) # check is no is negative num < 0: print("sorry ") elif num == 0: print("The factorial of 0 is 1") else: print("The factorial of",num,"is",factorial(num))
No comments:
Post a Comment