Created
November 27, 2018 14:25
-
-
Save renzon/9b067045bc0d12a4ed52f4bc57e41c05 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 fat(n): | |
def fat_iter(i, result): | |
if i > n: | |
return result | |
return fat_iter(i + 1, result * i) | |
return fat_iter(1, 1) | |
def test(): | |
assert 1 == fat(0) | |
assert 1 == fat(1) | |
assert 2 == fat(2) | |
assert 6 == fat(3) | |
assert 24 == fat(4) | |
assert 120 == fat(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment