Let $n$ be a positive integer and let $a_1, a_2, \cdots a_k$ be all numbers less than $n$ and coprime to $n$ in increasing order. Find the set of values the function $f(n)=gcd(a_1^3-1, a_2^3-1, \cdots, a_k^3-1)$.
Problem
Source: St Petersburg 2022 10.5
Tags: function, number theory
29.09.2022 00:56
I show $f(n)=2$ for $n>32$ is even and $f(n)=1$ for $n>7$ is odd. The rest is easy casework (I omit), details below. Case 1. $n$ is odd or $n$ is even but $3\nmid n$. In this case, $a_2=2$ implies $f(n)\mid 7$. Hence $f(n)\in\{1,7\}$. The cases $n<7$ are easily inspected, let $n\ge 7$. Note that if $7\mid f(n)$ then $7\nmid (n-1)^3-1$ (as $a_k=n-1$). In particular, $7\nmid n$. But then, $a_i=7$ for some $i$, yielding a contradiction. Thus in this case we get $f(3)=7,f(5)=f(7)=1$. Next, suppose $n$ is even with $3\nmid n$. Then $a_2=3$. In particular, $f(n)\mid 3^3-1=26$. Clearly $2\mid f(n)$, thus we inspect whether $13\mid f(n)$. Once again, $n<13$ is easily studied, so suppose $n\ge 13$. If $13\mid f(n)$ for some $n\ge 13$, we get $13\nmid n$, thus $a_i=13$ for some $i$, again a contradiction. Verify $n<13$ manually. Case 2. $6\nmid n$. This is the interesting case. We show for $n>32$, $f(n)=2$; whereas $n\in\{6,12,\dots,30\}$ are easily investigated manually. To that end, let $q\mid f(n)$ be an odd prime. Note that $q\ge n+1$. Indeed, otherwise $q\mid (n-1)^3-1$ implies $q\nmid n$, but then $a_i=q$ for some $i$, a contradiction. Now, using inequality $\phi(n)\ge \textstyle\sqrt{n/2}$ (see here for a proof) we get that for $n\ge 32$, $\phi(n)\ge 4$. We next study $q\mid a_i^3-1$ for $i=2,3,4$. Clearly $q\nmid a_i-1$ as $q>n$, so $q\mid a_i^2+a_i+1$. Now, we easily see that $q\mid x^2+x+1, y^2+y+1\implies q\mid (x-y)(x+y+1)$. Thus $q\mid (a_i-a_2)(a_i+a_2+1)$ for each $i$. But then $q\mid a_i+a_2+1$. From here, we get $q\mid a_4-a_3$ but as $a_4-a_3<n$, we have a contradiction. Hence, there is no $q>2$ prime dividing $f(n)$ if $n\ge 32$. Finally, we show $4\nmid f(n)$. For this, we show there is an $a<n$ such that $a\equiv 3\pmod{4}$ and $(a,n)=1$. If $4\mid n$, this is trivial by the CRT, so suppose $4\nmid n$. Let $n=2m$ for $m$ odd. We cook $n_1$ such that \[ n_1\equiv 3\pmod{4}\quad\text{and}\quad n_1\equiv 1\pmod{m}. \]Likewise, cook $n_2$ such that \[ n_2\equiv 3\pmod{4}\quad\text{and}\quad n_1\equiv -1\pmod{m}. \]Note that if $\min\{n_1,n_2\}\le n$, we are done. So assume the contrary that $n_1,n_2>n$. Since $n_1,n_2<4m=2n$, we get $2m<n_1+n_2<4m$. Moreover, $m\mid n_1+n_2$, so $n_1+n_2=3m$. But now, $n_1+n_2$ is even, whereas $3m$ is odd, a contradiction. Thus such a number exists, forces $f(n)=2$, as desired.