Determine all integers with the following property: every pairwise distinct integers whose sum is not divisible by can be arranged in some order so that divides .
Problem 1989
Official solution
Answer: All odd integers and all powers of .
If , where is odd and is a positive integer, we can consider a set containing the number and numbers congruent to modulo . The sum of these numbers is congruent to modulo and therefore is not divisible by ; for any permutation of these numbers
and a fortiori is not divisible by .
From now on, we suppose that is either odd or a power of . Let be the given set of integers, and be the sum of elements of .
Lemma 1. If there is a permutation of such that divides , then there is a permutation of such that divides .
Proof. Let . Consider the permutation defined by , where . For this permutation, we have
Since divides , the congruence admits a solution.
Lemma 2. Every set of integers, , can be partitioned into sets of integers so that in every set either the sum of elements is not divisible by or all the elements leave the same remainder upon division by .
Proof. The base case, . If contains elements leaving the same remainder upon division by , we form one subset of these elements; the remaining elements form a subset . If does not divide the sum of all elements of , we are done. Otherwise it is enough to exchange any element of with any element of not congruent to it modulo , thus making sums of both and not divisible by . This cannot be done only when all the elements of are congruent modulo ; in this case any partition will do.
If no elements of have the same residue modulo , there are three elements leaving pairwise distinct remainders upon division by . Let be the sum of elements of . It suffices to find such that and : then neither the sum of elements of nor the sum of elements of is divisible by . Consider with . The sums of elements of three sets leave three different remainders upon division by , and at least one of them is not congruent either to or to .
Now let . If contains elements leaving the same remainder upon division by , we form one subset of these elements and apply the inductive hypothesis to the remaining elements. Otherwise, we choose any . Since all the remaining elements cannot be congruent modulo , there is such that . Now we can take and apply the inductive hypothesis to .
Now we are ready to prove the statement of the problem for all odd and . The proof is by induction.
If is prime, the statement follows immediately from Lemma 1, since in this case . Turning to the general case, we can find prime and an integer such that and . By Lemma 2, we can partition into sets of elements so that in every set either the sum of numbers is not divisible by or all numbers have the same residue modulo .
For sets in the first category, by the inductive hypothesis there is a permutation such that .
If (and therefore ) is odd, then for each permutation of a set in the second category we have
By combining such permutation for all sets of the partition, we get a permutation of such that . Since this sum is divisible by , and is divisible by , we are done by Lemma 1.
If , we have and . Then for each of the subsets there is a permutation such that is divisible by : if the subset belongs to the first category, the expression is divisible even by , and if it belongs to the second one,
Now the numbers of each permutation should be multiplied by all the odd or all the even numbers not exceeding in increasing order so that the resulting sums are divisible by :
Combining these two sums, we again get a permutation of such that , and finish the case by applying Lemma 1.