A sequence $a_2, a_3, \dots, a_n$ of positive integers is said to be campechana, if for each $i$ such that $2 \leq i \leq n$ it holds that exactly $a_i$ terms of the sequence are relatively prime to $i$. We say that the size of such a sequence is $n - 1$. Let $m = p_1p_2 \dots p_k$, where $p_1, p_2, \dots, p_k$ are pairwise distinct primes and $k \geq 2$. Show that there exist at least two different campechana sequences of size $m$.
Problem
Source: Mexico National Olympiad 2018 Problem 3
Tags: number theory, relatively prime
06.11.2018 06:56
07.11.2018 17:38
Here's a writeup of the official solution. A second, different solution was also found during grading at the national contest, I'll write that one up later. We first construct one sequence by letting $a_n = \frac{m}{\gcd(m, n)}$. We claim that this sequence is indeed campechana. The key is that this construction guarantees that each one of the primes $p_i$ will divide $a_n$ if and only if $p_i$ does not divide $n$. It now follows that for a general $n$ and $d = \gcd(m, n)$, we will have $(a_i , n) > 1$ for any $i$ that is not a multiple of $\gcd(m, n)$. Moreover, if $i$ is a multiple of $\gcd(m, n)$, then because $m$ is squarefree, any $p_r$ that divides $d$ will not divide $a_i$, as the latter divides $\frac{m}{d}$ which is coprime to $n$. Therefore $(a_i, n) = 1$ if and only if $i$ is a multiple of $\gcd(m, n)$, of which there are exactly $\frac{m}{\gcd(m, n)} = a_n$ in $\{2, 3, \dots, m + 1\}$. Now, in order to construct the second sequence, we will look at the prime factorizations of the terms $a_i$ in the original sequence, and construct a new sequence $a'$ by swapping all appearances of $p_1$ and $p_2$, thus $a'_n = a_n$ if either both or neither of $p_1$ and $p_2$ divide $a_n$. This new sequence is similar to the first, with the difference that now $p_1$ divides $a_n$ if and only if $p_2$ does not divide $n$, and vice versa. We can now verify that this sequence is campechana analogously to the first one. As an added note, the bound that at least two campechana sequences exist is not tight for any $k > 2$, as in fact the above argument can be modified to employ any involution of $\{p_1, p_2, \dots, p_k\}$ rather than a single swap of $p_1$ and $p_2$.
09.11.2018 03:25
Here's the one other essentially different solution that was presented during the contest. I thought this one was fairly natural, but not very many of the contestants got any progress relative to this solution so... The main claim is that if $a_2, a_3, \dots, a_{n + 1}$ and $b_2, b_3, \dots, b_{m + 1}$ are campechana sequences of sizes $n$ and $m$, where $(m, n) = 1$, then the sequence $(c_i)_{i = 2}^{mn + 1}$ given by $c_i = a_ib_i$, where $a_i = a_{i \bmod{n}}$ and $b_i = b_{i \bmod{m}}$ is also campechana. This follows from the fact that $(i, c_k) = 1$ if and only if $(i, a_k) = 1$ and $(i, b_k) = 1$, and by CRT, every pair $(x, y)$ such that $(i, a_x) = 1$ and $(i, b_y) = 1$ gives a unique $z$ such that $c_z = a_xb_y$, and $(i, c_z) = 1$. As $(a_i)$ and $(b_i)$ are campechana by assumption it follows from this that there are $a_i$ possible values for $x$ and $b_i$ possible values for $y$, and therefore there are $a_ib_i$ such pairs $(x, y)$, giving $a_ib_i$ indices $z$ such that $(i, c_z) = 1$. Therefore $(c_i)$ is campechana. Now it suffices to find one campechana sequence of size $p$ and two of size $pq$ for any two different primes $p$ and $q$. But this is easy, as it is straightforward to verify that $p, p, p, \dots, p, 1, p$ works for the first case, while $a_i = \gcd(m, i)$ and $a_i = \frac{m}{\gcd(m, i)}$ both work for the second case.