Skip to content

Instantly share code, notes, and snippets.

@mashcom
Created June 16, 2014 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashcom/e55cc1635601efc5d2fe to your computer and use it in GitHub Desktop.
Save mashcom/e55cc1635601efc5d2fe to your computer and use it in GitHub Desktop.
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