020. Odd 8-Bit Numbers
Find the largest odd number that divides the sum of the natural numbers less than or equal to 255 in which 1 appears an odd number of times when expressed in binary.
Among the natural numbers less than 255, there are 128 that have an odd number of 1s when expressed in 8-bit binary.
Now, let be a natural number less than or equal to 255 that has an odd number of 1s when expressed in binary. If changing 0 to 1 and 1 to 0 for this , that becomes
Since subtracting an odd number from 8 is also an odd number, the value above also has an odd number of 1s when expressed in binary. So, if thinking about it in pairs, the sum of all numbers with an odd number of 1s is
Therefore, the largest odd number that divides this sum is 255.