Dropbox sync metadata can represent several file properties as individual bits in a nonnegative integer. Given an integer n, return the number of set bits, meaning the number of 1 values in its binary representation.
Implement the function without converting the number to a string or iterating through every position in a fixed-width representation. Aim for runtime proportional to the number of set bits rather than the total bit width.
n.n.0 has zero set bits.n as an unsigned value. Inputs do not contain negative numbers.def count_set_bits(n):