Skip to content

Instantly share code, notes, and snippets.

@coltin
Created July 23, 2015 00:42
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 coltin/4911e8b57e3d8a8ad45b to your computer and use it in GitHub Desktop.
Save coltin/4911e8b57e3d8a8ad45b to your computer and use it in GitHub Desktop.
# Author Sarah Bryant
# July 22, 2015
#YOLO
# 5! = 120
def factorial(n):
solution = 1
while n > 1:
solution = solution * n
n = n - 1
return solution
print "1! =", factorial(1)
print "2! =", factorial(2)
print "3! =", factorial(3)
print "5! =", factorial(5)
print "20! =", factorial(20)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment