fork download
  1. def BaseConvert(n, b):
  2. k = 1
  3. x = []
  4. while b**(k-1) < n:
  5. d = (n % b**k)
  6. n -= d
  7. x.append(d/b**(k-1))
  8. k += 1
  9. return x
  10.  
  11. def FouriestTransform(n):
  12. maxfours = 0
  13. b = 5
  14. while 4*b**(maxfours) < n and b < n:
  15. fours = BaseConvert(n,b).count(4)
  16. if fours > maxfours:
  17. maxfours = fours
  18. b += 1
  19. return maxfours
  20.  
  21. print FouriestTransform(1524)
  22. print FouriestTransform(66)# your code goes here
Success #stdin #stdout 0.01s 7852KB
stdin
Standard input is empty
stdout
3
1