fib.py 354 Bytes
Newer Older
josd's avatar
josd committed
1 2 3 4 5 6
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]

josd's avatar
josd committed
7 8 9 10 11 12
if __name__ == "__main__":
    print('PREFIX : <http://josd.github.io/eye/imagining#>')
    print('')
    print('0 :fib %d .' % (fib(0)))
    print('91 :fib %d .' % (fib(91)))
    print('283 :fib %d .' % (fib(283)))