Consider the permutation of , which we denote as .
Let be the number of these permutations satisfying the following conditions:
(1) ;
(2) .
What is the residue when we divide by 4?
Problem 1788
Official solution
Solution: We discuss below the recurrence for . Suppose satisfies the conditions of the problem; since , we have or .
(Case 1): . Let , then satisfies the conditions of the problem, so the number of permutations in this case is .
(Case 2): and , then we must have . Consider , then satisfies the conditions of the problem, so the number of permutations in this case is .
(Case 3): and . Suppose is the first even number to appear in this permutation. By condition 2, are , and or .
(Case 3-1): . By discussion, the only possibility is .
(Case 3-2): . By discussion, the only possibility is .
Therefore, Case 3 has only one possibility: first arrange in increasing order all positive odd numbers , then arrange in decreasing order all positive even numbers .
Combining the above, we have
Using this formula to compute, we find that the residues of modulo 4, in order, are:
1, 1, 2, 0, 2, 1, 2, 1, 3, 2, 0, 0, 3, 0, 1, 1, 2, 0, 2, ...
which is a sequence with period 14. Also, 2015 = 143 14 + 13, so