Skip to content

Instantly share code, notes, and snippets.

@mashcom mashcom/factorial.py
Created Jun 16, 2014

Embed
What would you like to do?
calculate factorials in python.
# calculate factorial
# @author: Mashoko Blessing
# @http://www.facebook.com/blessing.mashcom
# @mashcom digimedia http://www.hookd-up.com
#email: bmashcom@hotmail.com
def factorial(x):
if(x==0):
return 1
else:
return x*factorial(x-1)
print("please enter the number you want to do a factorial for \n")
x= input()
print(factorial(int(x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.