Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
7
Task/Fibonacci-sequence/Python/fibonacci-sequence-9.py
Normal file
7
Task/Fibonacci-sequence/Python/fibonacci-sequence-9.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue