Description
Given a number, print the amount of 1
s 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 1
s 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