Created
April 26, 2023 10:00
-
-
Save zoten/264bff83c54374f3e8016a12f7c02180 to your computer and use it in GitHub Desktop.
Forbidden Python
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
class Fib(dict): | |
def __init__(self): | |
self[0] = self[1] = 1 | |
def __missing__(self, k): | |
fibk = self[k] = self[k - 1] + self[k - 2] | |
return fibk | |
fib = Fib() | |
print(fib[10]) | |
print(fib[100]) | |
print(fib[200]) | |
print(len(fib)) | |
# 89 | |
# 573147844013817084101 | |
# 453973694165307953197296969697410619233826 | |
# 201 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment