How many ones are used in writing all of the numbers from 0 to 2018 (inclusive) in binary form?
Well, 2048 = 2^11
So, there are 2048 numbers from 0 to 2047, and half of them have a 1 in each of eleven places, for a total of 1024 * 11 = 11,264 ones.
So all I need to do is subtract the 1's in 2019 through 2047 inclusive. That should be easy, but it is too hot right now.
(Fixed to reflect correct number of digits as 11)
Edited on June 18, 2018, 3:49 pm