Example 4 Write the positive integers $1,2, \cdots, n(n \geqslant 3)$ on the blackboard. Each time, replace two numbers $p, q$ with $p+q$ and $|p-q|$. After several transformations, all the numbers become $k$. What values can $k$ take?
Solve (using the method of invariants and mathematical induction) If $p+q$ and $p-q$ are divisible by an odd number $d (\geqslant 3)$, then $p+q+(p-q)=2p$, $p+q-(p-q)=2q$ are also divisible by $d$, hence $p, q$ are both divisible by $d$. Therefore, if $k$ is divisible by $d (\geqslant 3)$, then initially $1,2,3, \cdots, n$ are all divisible by the odd number $d (\geqslant 3)$ (divisibility invariant), which is impossible. Hence, $k$ can only be of the form $2^{t} (t$ being a positive integer), and after each operation, the largest number on the blackboard does not decrease, so $k=2^{t} \geqslant n$.
Next, we prove that $k$ can take any positive integer of the form $2^{t} \geqslant n$ (where $t$ is a positive integer).
Notice that $\left(2^{a}, 2^{a}\right) \rightarrow\left(0, 2^{a+1}\right)$ and $\left(0,2^{c}\right) \rightarrow\left(2^{c}, 2^{c}\right)$, so it is not difficult to see: if all the numbers on the blackboard are powers of 2 (including the zeroth power), their exponents do not exceed $b_{0}$, and at least two of them are equal and less than $2^{b_{0}}$, then after a finite number of operations, all the numbers can be made to become $2^{b_{0}}$.

Therefore, we only need to use induction on $n \geqslant 3$ to prove the following conclusion: starting from the sequence $1,2, \cdots, n$, after a finite number of operations, all $n$ numbers can be made to become powers of 2, with exponents not exceeding $b_{0}$, and at least two of them are equal and less than $2^{b_{0}}$, where $b_{0}$ is any positive integer satisfying $2^{b_{0}} \geqslant n$.

Since $(1,3) \rightarrow(2,4)$, we know that the conclusion holds for $n=3,4$. Also, since $(3,5) \rightarrow(2,8)$, $(2,6) \rightarrow(4,8)$, $(1,3,5,7) \rightarrow(6,2,8,8) \rightarrow(8,4,8,8)$, we know that the conclusion also holds for $n=5,6,7,8$. Assume the conclusion holds for all positive integers $n$ such that $3 \leqslant n \leqslant m-1 (m \geqslant 9)$, and then prove that the conclusion also holds for $n=m (m \geqslant 9)$. Let $m=2^{b-1}+r$, where $b \geqslant 4, 1 \leqslant r \leqslant 2^{b-1}$. If $r=2^{b-1}$, i.e., $m=2^{b}$, then applying the induction hypothesis to $(1,2, \cdots, m-1)$, we know the conclusion holds. Now assume $1 \leqslant r \leqslant 2^{b-1}$. At this point, we sequentially operate on the pairs $(p, q)=\left(2^{b-1}-i, 2^{b-1}+i\right) (i=1,2, \cdots, r)$, thus the $n$ numbers can be divided into 3 categories:
(1) $1,2,3, \cdots, 2^{b-1}-r-1$ (numbers on the blackboard that have not been operated on, if $r=2^{b-1}-1$, this part does not exist).
(2) $2,4,6, \cdots, 2r$ (these numbers are obtained from the difference $|p-q|$).
(3) $2^{b-1}, 2^{b}, \cdots, 2^{b}$ (these numbers are obtained from the sum $p+q$ and $2^{b-1}$).
If $2^{b-1}-r-1 \leqslant 2$ and $2r \leqslant 2$, then $2^{b-1} \leqslant r+3 \leqslant 4, b \leqslant 3$, which contradicts $b \geqslant 4$, hence at least one of the two groups (1) and (2) has at least 3 numbers. If the number of numbers in both groups (1) and (2) is not less than 3, then by the induction hypothesis, the conclusion holds; if only one of the two groups (1) and (2) has at least 3 numbers, then apply the induction hypothesis to that group, and the remaining two parts are already all powers of 2, so the conclusion also holds. This completes the inductive proof.