def memoize(func):
    memo = {}
    def wrapper(n): 
        if n in memo:
            return memo[n]
        memo[n] = func(n)
        return memo[n]
    return wrapper

@memoize
def fib(n):
    if n <= 2:
        return 1
    return fib(n - 1) + fib(n - 2)

for i in range(1,10):
    print(fib(i))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: