Python program to find the factorial of the number
'''
Python program to find the factorial of the number
'''
# The given number (input)
num = 10
factorial = 1
# Check if the number is positive , negative or zero.
if num < 0:
print("Negative number factorial does not exist.")
elif num == 0:
print("The factorial of 0 is 0.")
else:
for i in range ( 1, num+1 ) :
factorial = factorial * i
print(f" The factorial of {num} is {factorial}.")
# OR There are other method to get the factorial by recursion (function inside same function)----------
def function1(num1):
if num1 == 1:
return 1
else:
return (num1 * function1(num1 - 1))
function1(10)
print(f"The factorial of {10} is {function1(10)}.")
Very nice 👍 good job🤟
ReplyDelete