Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sdelquin
Created January 25, 2019 19:09
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 sdelquin/f511200029deae3856226ee2b581c09a to your computer and use it in GitHub Desktop.
Save sdelquin/f511200029deae3856226ee2b581c09a to your computer and use it in GitHub Desktop.
Factorial made in Python
def recursive_factorial(n):
if n == 1:
return 1
return n * recursive_factorial(n - 1)
def iterative_factorial(n):
result = 1
for i in range(2, n+1):
result *= i
return result
print(iterative_factorial(4))
print(recursive_factorial(4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment