Skip to content

Instantly share code, notes, and snippets.

@edenau
Created February 23, 2020 21:04
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 edenau/4fdd68a734cf8f2d87a3b1dbb6a829ff to your computer and use it in GitHub Desktop.
Save edenau/4fdd68a734cf8f2d87a3b1dbb6a829ff to your computer and use it in GitHub Desktop.
def factorial(n):
assert n >= 0 and int(n) == n, 'Factorial function is defined for non-negative integers only!'
if n in [0,1]:
return 1
else:
return n * factorial(n-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment