Number of Ones in Binary

Number of Ones in Binary

Given a number as input, write a program that will find the binary representation of the number and print the number of 1 bits in that representation. For example, the number 17 in binary is 10001. This has three 0 bits and two 1 bits so the output should be 2.

Example 1:


input data:
15
output:
4

Example 2:


input data:
61
output:
5
View Java Solution

Seda
Seda Kunda is a web designer and developer with a degree in Computer Science and a great passion for code. Besides code, she enjoys pepperoni pizza, watching the bachelor and sleeping in on Saturdays.
Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedIn