Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def f(curr, end):
- if curr > end:
- return 0
- if curr == end:
- return 1
- if curr < end:
- return f(curr + 1, end) + f(curr + 3, end) + f(curr * 2, end)
- print(f(1, 15))
- a = [0] * 100
- a[1] = 1
- for i in range(1, 15):
- if i + 1 <= 15:
- a[i + 1] += a[i]
- if i + 3 <= 15:
- a[i + 3] += a[i]
- if i * 2 <= 15:
- a[i * 2] += a[i]
- print(a[15])
Advertisement
Add Comment
Please, Sign In to add comment