For an integer , the tuple is written on a blackboard. On each turn, one can choose two numbers from the tuple such that their sum is a perfect square and swap them to obtain a new tuple. Find all integers for which all permutations of can appear on the blackboard in this way.
, 2023
Solution
Answer: All integers .
We first note that we say the numbers and can be ultimately swapped if, after a number of moves, one can obtain the tuple in which only and are swapped. We now prove a result.
Claim. If integers are such that the numbers can be ultimately swapped and the numbers can be ultimately swapped, then can be ultimately swapped.
Proof. If we swap then and again it would be the same as swapping just .
abc bac bca acb.
Now, consider the graph where vertices correspond to the elements of the set and an edge is drawn between two distinct integers whenever their sum is a perfect square. We can swap any numbers when there is an edge between them and by the claim above, any two numbers can be ultimately swapped when there is a path between them. Hence, we can obtain all the possible permutations if and only if this graph is connected.
We observe that any positive integer is connected to a positive integer smaller than . This can be easily seen if . Suppose and take such that . Then is connected and holds as .
Hence, there are at most 3 connected components in this graph for any . For , we have , and as the connected components and the graph is still disconnected. 13 is connected to both 3 and 12, hence it reduces the number of components to 2; finally 14 is connected to 2 and 11 thus when , there is a unique connected component.