Skip to content

Instantly share code, notes, and snippets.

@zoten
Created April 26, 2023 10:00
Show Gist options
  • Save zoten/264bff83c54374f3e8016a12f7c02180 to your computer and use it in GitHub Desktop.
Save zoten/264bff83c54374f3e8016a12f7c02180 to your computer and use it in GitHub Desktop.
Forbidden Python
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