Problem: Number Of 1 Bits
Return the number of set bits in an unsigned integer.
Hidden answer: strategy, invariant, mistakes, tests
Use n & (n - 1) to remove the lowest set bit until
n is zero. Invariant: after each loop, the answer
counts exactly the set bits removed so far. Mistake to avoid:
looping while shifting a negative value if the input is signed.
Test zero, one, a power of two, all bits set, and alternating bits.