aboutsummaryrefslogtreecommitdiff
path: root/challenge-112/colin-crain/python/ch-2.py
blob: 750a1657372a2a541e399677a563eb8a5801377a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
#
#
#       one-two-up-we-go.py
#
#
#
#       © 2021 colin crain
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##



from functools import lru_cache

@lru_cache(maxsize = 1000)
def fib(n):
    if n < 0:
        return None
    if n < 2:
        return n
    else:
        return fib(n-1) + fib(n-2)


for i in range(2, 21):
    ways = fib(i+1)
    print(f"for {i} steps there are {ways} ways to climb them")