Question
Given a positive integerÂ
n
, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).
This is abit_manip question.
Idea
- Convert the decimal number to binary, but instead of keeping a string just add the binary representation to res
- The output will be the sum of all 1’s