This is the question I get from Geeks For Geeks.
The problem is, given the first $50$ natural numbers, i.e., from $1$ to $50$ which are written on a board. Select two of the numbers on the board, say $a$ and $b$, write the absolute value of their difference $|a - b|$ on the board and then erase both $a$ and $b$. Apply the above operation $49$ times. Determine all possible values of the remaining number that can be obtained in this manner.
Here is the link of the question with the solution. Step $6$ to $8$ are here:
- Also given that all the numbers on the board are always nonnegative. They are also less than or equal to $50$, since $|a - b|$ is always less than or equal to the maximum of $a$ and $b$ for nonnegative $a$ and $b$. Now, any odd integer from $1$ to $49$, inclusive, can be obtained by applying the puzzle’s operation $49$ times.
- Let $k$ be such a number. This can be obtained in the first iteration by subtracting $1$ from $k + 1$ as $|1 - (k + 1)| = k$.
- Then, apply the operation to the pairs of the remaining consecutive integers, $(2, 3), (4, 5), . . . , (k – 1, k), (k + 2, k + 3), . . . , (49, 50)$, to get $24$ ones on the board while erasing the above pairs.
I cannot get what does author mean in step $8$, why choose the number in a way that in order? why not $(2,4),(3,5),(6,9)$ and so on? This is my first question.
Next, if we erase $a$ and $b$ from board, new number added, the author seems not adding that instantly after the erasing of $a$ and $b$. For exp, in step $6$ we obtain a number $k$, so $k$ should be added into the board for next calculation right?
These are my question, thanks in advanced!