20. Count Set Bits in an 8-bit Register

You are given an 8-bit register. Count how many bits are set to 1 (i.e., high) in the register.


Example 1

Input: reg = 0b0000 1111 
Output: 4


Example 2

Input: reg = 0b1111 0000 
Output: 4


Example 3

Input: reg = 0b0000 0000 
Output: 0


Example 4 

Input: reg = 0b1111 1111 
Output: 8

 


 

Loading...

Input

0

Expected Output

0