Skip to main content
edited tags
Link
Wheat Wizard
  • 100k
  • 22
  • 282
  • 661
edited tags
Link
user41805
  • 13.2k
  • 6
  • 42
  • 88
Tweeted twitter.com/#!/StackCodeGolf/status/153073860936335360
Source Link
pimvdb
  • 859
  • 8
  • 16

Print the amount of ones in a binary number without using bitwise operators

Description

Given a number, print the amount of 1s it has in binary representation.

Input

A number >= 0 in base 10 that won't exceed the highest number your language is able to handle.

Output

The amount of 1s in binary representation.

Winning condition

The shortest code wins.

Disallowed

  • Bitwise operators. Other operators, like addition and multiplication, are allowed.
  • Built-in base conversion functions.

Examples

Input:     Ouput:

56432      8


Input:     Output:

45781254   11


Input:     Output:

0          0