Farz0l1x

Untitled

Feb 24th, 2023
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def t(n):
  2.     if n % 2 == 0:
  3.         return n * 1.5
  4.     else:
  5.         return n + 1
  6. def f(curr, end):
  7.     if curr > end:
  8.         return 0
  9.     if curr == end:
  10.         return 1
  11.     if curr < end:
  12.         return f(curr + 1, end) + f(t(curr), end)
  13. print(f(1, 20))
  14.  
  15. a = [0] * 100
  16. a[1] = 1
  17. for i in range(1, 20):
  18.     if i + 1 <= 20:
  19.         a[i + 1] += a[i]
  20.     if t(i) <= 20:
  21.         a[t(i)] += a[i]
  22. print(a[20])
Advertisement
Add Comment
Please, Sign In to add comment