What is the total running time of counting from 1 to n in binary if the time needed to add 1 to the current number i is proportional to the number of bits in the binary expansion of i that must change in going from i to i + 1?
Having trouble getting my head a around this one because I cannot find a formula for how bits change from some i to i+1. for example $$~~~~before~~~~~~after~~~~changes$$ $$0000 -> 0001 = 1$$ $$0001 -> 0010 = 2$$ $$0010 -> 0011 = 1$$ $$0011 -> 0100 = 3$$