dxnge

task 2

Sep 23rd, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.26 KB | None | 0 0
  1. def F(n):
  2.     if n == 0:
  3.         return 0
  4.     if n > 0 and n % 3 == 0:
  5.         return F(n//3)
  6.     if n % 3 > 0:
  7.         return (n % 3) + F(n - (n % 3))
  8.  
  9.  
  10. def G(n):
  11.     if F(n) == 9:
  12.         return n
  13.     return G(n+1)
  14.  
  15.  
  16. print(G(0))
  17.  
  18. print(F(161))
Advertisement
Add Comment
Please, Sign In to add comment