Farz0l1x

Untitled

Feb 24th, 2023
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 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 + 2, end) + f(curr + 4, end) + f(curr + 5, end)
  8. for i in range(31, 1000):
  9.     if f(31, i) == 1001:
  10.         print(i)
  11.        
  12. a = [0] * 100
  13. a[31] = 1
  14. for i in range(31, 60):
  15.     if i + 2 <= 60:
  16.         a[i + 2] += a[i]
  17.     if i + 4 <= 60:
  18.         a[i + 4] += a[i]
  19.     if i + 5 <= 60:
  20.         a[i + 5] += a[i]
  21.     if a[i] == 1001:
  22.         print(i)
Advertisement
Add Comment
Please, Sign In to add comment