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!
The goal is to show that exactly all odd integers between 1 and 49 inclusive can be constructed.
So first, the author shows that only those values could possibly be reached, because the sum of all numbers always remains odd and one can not create integers less than 0 or greater than 50. (steps 1 to 5).
Then he shows that all those values can be reached. To do so, he chooses such a k and exhibits a construction where this k is constructed within the first step via $k = k+1-1$ and never touched again until the very end where he does $k = k-0$. After step 1 he thus has two $k$'s at his disposal : the original one and the one he just obtained. One of them is going to be used up in the pairings, the other one kept until the end.
And as for why he chooses to pair does particular numbers together: well, because he can and because it works. He is free to chooses whatever pairs he likes, so he chooses those which lead him easily to his goal of ending up with a $0$ and a $k$. He first creates a bunch of $1$'s while leaving $k$ alone, creates a bunch of $0$'s out of those $1$'s and then lets all these $0$'s "cancel out", until he's left with only $0$ and the $k$ he saved from step 7.
(I don't know if this deserves to be a full blown answer, I would post it as a comment but don't have the necessary reputation)