7 lines
216 B
Python
7 lines
216 B
Python
def fib(n, c={0:1, 1:1}):
|
|
if n not in c:
|
|
x = n // 2
|
|
c[n] = fib(x-1) * fib(n-x-1) + fib(x) * fib(n - x)
|
|
return c[n]
|
|
|
|
fib(10000000) # calculating it takes a few seconds, printing it takes eons
|