Advertisement
stupid_pro

кэшик

Feb 19th, 2023 (edited)
549
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. import sys
  2. sys.setrecursionlimit(3000)
  3. def fact(n):
  4.     if n== 0:
  5.         return 1
  6.     else:
  7.         return n * fact(n-1)
  8.  
  9. print(fact(2000))
  10.  
  11. import sys
  12. sys.setrecursionlimit(3000)
  13.  
  14. from functools import lru_cache
  15.  
  16. @lru_cache()
  17. def F(n):
  18.     if n<=1:
  19.         return n
  20.     elif n % 4 ==0:
  21.         return n + F(n/4 - 1)
  22.     else:
  23.         return -1*10**30
  24.  
  25. for i in range(1, 10000):
  26.     if F(i)>2000:
  27.         print(i)
  28.         break
  29.  
  30.  
  31. def f(i,finish):
  32.     if i<finish:
  33.         return 0
  34.     elif i==finish:
  35.         return 1
  36.     else:
  37.         return f(i-1, finish)+f(i-3, finish)+ f(i//3,finish)
  38.  
  39. print(f(22,2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement