Let be a positive integer greater than . The teacher writes positive integers on the blackboard, whereby the last of them, let it be , is not divisible by . Can Mary always denote the first integers written by the teacher by in such an order that the product were congruent to either or modulo ?
, 2013
Solution
Answer: Yes.
If some two of the first integers are congruent modulo then Mary can choose them consecutively and obtain a product divisible by . Hence we may assume in the rest that the first integers written by the teacher are pairwise incongruent modulo . This means that these integers cover all residues modulo .
If is composite then Mary can find integers and such that and . Let Mary denote such that , , and . The remaining numbers can be denoted in arbitrary order. The product is divisible by as the product of the first and the third factor is .
If is prime then the numbers , where , cover all residues modulo . Let Mary denote the numbers in such a way that for every . Then every factor in the product is congruent to modulo , meaning that the product is congruent to modulo . But by Fermat's theorem, and Mary has done.