One way to think about this is to sum across the columns rather than the rows. Suppose you're counting up to 2k. Then:
- In all 2k operations, the 1's bit will flip.
- In 2k / 2 = 2k-1 of those operations, the 2's bit will flip.
- In 2k / 4 = 2k-2 of those operations, the 4's bit will flip.
- In 2k / 8 = 2k-3 of those operations, the 8's bit will flip.
- ...
- In 2k / 2k = 1 of those operations, the 2k's bit will flip.
(In the above, I'm counting adding a new 1 digit in as a "flip" rather than an "add" because you can think of it as either flipping from 0 to 1 or adding a new 1 digit to the front.)
This means that the total number of bits that have to change is given by
2k + 2k-1 + 2k-2 + ... + 1
= 2k+1 - 1
So there will be a total of 2k+1 - 1 bits flipped. We can check this: counting from 0 to 1, we get
0
1
So one bit is flipped (1 = 21 - 1, as we predicted). When counting from 0 to 2, we get
00
01
10
That's a total of three bit flips (0 -> 1 -> 0 in the 1's place and 0 -> 1 in the 2's place), and 3 = 22 - 1, as we guessed.
Hope this helps!