Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

Python, 46 45 bytes, Sp3000Python, 46 45 bytes, Sp3000

f=lambda n,k=1:n and-~f(n-(k+(k&-k)&k>0),k+1)

Test it on Ideone.

Python, 46 45 bytes, Sp3000

f=lambda n,k=1:n and-~f(n-(k+(k&-k)&k>0),k+1)

Test it on Ideone.

Python, 46 45 bytes, Sp3000

f=lambda n,k=1:n and-~f(n-(k+(k&-k)&k>0),k+1)

Test it on Ideone.

Source Link
Dennis
  • 210.6k
  • 41
  • 370
  • 825

Python, 46 45 bytes, Sp3000

f=lambda n,k=1:n and-~f(n-(k+(k&-k)&k>0),k+1)

Test it on Ideone.