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 * 2, end) + f(curr * 2 + 1, end)
- print(f(4, 29))
- a = [0] * 100
- a[4] = 1
- for i in range(4, 29):
- if i + 1 <= 29:
- a[i + 1] += a[i]
- if i * 2 <= 29:
- a[i * 2] += a[i]
- if i * 2 + 1 <= 29:
- a[i * 2 + 1] += a[i]
- print(a[29])
Advertisement
Add Comment
Please, Sign In to add comment