fork(4) download
  1.  
  2. def zeckendorf(n):
  3. # find the largest fibonacci number that <= n
  4. a, b = 1, 2
  5. while b <= n:
  6. a, b = b, a+b
  7.  
  8. # use greedy algorithm to get the representation
  9. while b > 1:
  10. if a <= n:
  11. yield 1
  12. n -= a
  13. else:
  14. yield 0
  15. a, b = b-a, a
  16.  
  17. print(*zeckendorf(int(input())), sep='')
  18.  
Success #stdin #stdout 0.01s 28384KB
stdin
34639092
stdout
101000010100101000000000100010010010