Factorial of a Number
There are a number of ways to find the factorial of a number (obviously, it going to a whole number 😆). Out of all of them today, I'm going to show you the user-defined code I created to find the factorial of any whole number. Trust me, it's cool 😎 just give it a try...
#Factorial Calculator
def fact(x):
p = 1
while x>0:
p = p*x
x = x-1
print(p)
print("Thank you for using factorial calculator ;)")
while True:
n = input("Enter a number:")
if n.isdigit()and int(n)>=0:
n = int(n)
fact(n)
break
©SGPython
Comments
Post a Comment