Skip to main content
Removed six bytes by incrementing x at beginning of function.
Source Link
Nick
  • 141
  • 3

Javascript, 2525 19

Using the fact that, for a 1-sparse binary number, x&2*x == 0:

f=x=>x+1&2*x+2f=x=>x++&2*x?f(x+1x):x+1x

Javascript, 25

Using the fact that, for a 1-sparse binary number, x&2*x == 0:

f=x=>x+1&2*x+2?f(x+1):x+1

Javascript, 25 19

Using the fact that, for a 1-sparse binary number, x&2*x == 0:

f=x=>x++&2*x?f(x):x
Source Link
Nick
  • 141
  • 3

Javascript, 25

Using the fact that, for a 1-sparse binary number, x&2*x == 0:

f=x=>x+1&2*x+2?f(x+1):x+1