Farz0l1x

Untitled

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