Created
February 23, 2020 21:04
-
-
Save edenau/4fdd68a734cf8f2d87a3b1dbb6a829ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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