fork(1) download
  1. def printLexTo(n):
  2. val=1
  3. while True:
  4. if val<=n:
  5. print("{0:b}".format(val))
  6. if 2*val <= n:
  7. val *= 2
  8. else:
  9. # get the smallest 0 bit
  10. bit = (val+1) & ~val
  11. # set it to 1 and remove the remainder
  12. val = (val+1)//bit
  13. if val==1:
  14. # there weren't any 0 bits in the string
  15. break
  16.  
  17. printLexTo(23)
Success #stdin #stdout 0.02s 9232KB
stdin
Standard input is empty
stdout
1
10
100
1000
10000
10001
1001
10010
10011
101
1010
10100
10101
1011
10110
10111
11
110
1100
1101
111
1110
1111