For what $n$ do the equations $ab = c, bc = a, ca = b$ have solutions mod $n$? In $\mathbb Z/(12)$ the elements $5, 7, 11$ have the property that the product of any two of them equals the third:
$$5 \times 7 = 11$$
$$7 \times 11 = 5$$
$$11  \times 5 = 7$$
I'm interested in generalizations of this.  For what integers $n$ does the set of equations $ab = c, bc = a, ca = b$ have solutions mod $n$?  Is there a way to describe all such solutions?
(Also would be interested in further generalizations -- for example, is there a cycle of four elements $a, b, c, d$ so that $ab = c, bc = d, cd =a, da=b$ mod $n$ for some $n$?)
 A: If we write your equations $\pmod 3$ and $\pmod 4$ we get
$$\pmod 3 \quad \pmod 4\\
-1 \times 1 = -1\quad 1 \times -1 = -1\\
1 \times -1=-1 \quad -1 \times -1=1\\
-1 \times -1=1 \quad -1 \times 1=-1$$
and you can apply the Chinese Remainder Theorem to get your values.  One way to get other solutions is to replace $3,4$ by any pair of coprime numbers greater than $2$.  We cannot use $2$ because $-1=1 \pmod 2$.  For example, if we use $5,7$ we work $\pmod {35}$ and get
$$29 \times 6=34\quad 29 \times 34=6\quad 6 \times 34=29$$
This suggests another approach.  If we replace $-1$ by $a$ in the above equations, the only one that is problematic is $a \times a=1$.  If we choose a modulus where $1$ has more square roots than $1, -1$  we can make it work.  A semiprime will do this for us.  If we replace $3$ by $15$ we have $4 \times 4=1, 11\times 11=1$ and we can get three solutions $\pmod {60}$.  There are certainly many more.
A: This is anything but comprehensive. Sorry about that.

For three variables we can find solutions from copies of the Klein Four group inside $\Bbb{Z}_n^*$. Those exist if and only if one of the following conditions holds:

*

*$n$ is divisible by two distinct odd primes,

*$4\mid n$, and $n$ is divisible by an odd prime, or

*$8\mid n$.

The resulting solutions have the further property that $a,b,c$ are all coprime to $n$. We can introduce an auxiliary common factor $q$ to all of $a,b,c,n$ to get a solution modulo $nq$ provided that $\gcd(q,n)=1$ by lifting a solution modulo $n$ while making all the variables divisible by $q$. This is straightforward by Chinese remainder theorem. For example with $n=12, \{a,b,c\}=\{5,7,11\}, q=5$ we arrive at the solution $A=5, B=55, C=35$ modulo $nq=60$. Observe that $5$ is a factor of all of $A,B,C$, and $A\equiv a$, $B\equiv b$, $C\equiv c$ modulo $12$. This latter trick does not expand the range of available moduli $n$, so it does not really advance our cause. I brought it up, because grouping solution by the gcd may lead to a classification of all three variable solutions.

We also have the following mechanism for getting solutions with more than three variables. I find it a bit curious, which is why I post this.
Let $L$ be the Pisano period modulo $m$. That is, we define the sequence $(F_i)_{i\ge0}$ by declaring $F_0=0$, $F_1=1$ and then $F_{i+2}\equiv F_{i+1}+F_i\pmod m$. We necessarily end up with a periodically repeating sequence $(F_i)_{i\ge0}$ in
$\Bbb{Z}_m$, where $L$ is the shortest period: $F_i=F_{i+L}$ for all $i$. Then let us choose $n$ and $g$ such that $g$ has multiplicative order $m$ in the group $\Bbb{Z}_n^*$. We then get a solution with $L$ variables modulo $n$ by declaring
$$a_i\equiv g^{F_i}\pmod n$$
for all $i$.
For example, when $m=4$, the sequence $(F_i)_{i\ge0}$ repeats with the period
$(0,1,1,2,3,1)$ of length $L=6$. The residue class $g=2$ has order four in $\Bbb{Z}_5^*$, so we get a solution with six variables modulo $n=5$:
$$a_0=1, a_1=2, a_2=2, a_3=4, a_4=3, a_5=2.$$

While that felt cool at first, do observe that this mechanism is a bit boring in the following sense. We can equally well:

*

*Select random residue classes $a_0,a_1$ modulo $n$, both coprime to $n$.

*Continue recursively: $a_{i+2}=a_ia_{i+1}$ for all $i$.

*And stop when we reach the end of the period. Only finitely many alternatives to consecutive pairs $(a_i,a_{i+1})$, so eventually we reach a period (by the pigeon hole principle), and have a solution with a somewhat unpredictable number of variables.

This is unsatisfactory in the sense that we don't have control of the number of variables  we end up with :-(.
A: This gives $abc \equiv a^2 \equiv b^2 \equiv c^2 \bmod n$. Working $\bmod p$ for $p$ a prime this gives $a, b, c = \pm d$ for some $d$ (when $p = 2$ the signs don't matter but that doesn't affect this argument). This gives $\pm d^3 = d^2$ so $d = 0, \pm 1$ which gives that either $a, b, c = \pm 1$ and two or none of them are negative, or they're all zero; that is, we have
$$(a, b, c) \equiv (0, 0, 0), (1, 1, 1), (1, -1, -1), (-1, 1, -1), (-1, -1, 1) \bmod p.$$
These continue to be solutions $\bmod p^k, k \ge 1$ so using the Chinese remainder theorem we can construct nontrivial solutions (regarding $(0, 0, 0)$ and $(1, 1, 1)$ as trivial solutions) $\bmod n$ for all $n$ except $n = 2$. If you also regard the $\pm 1$ solutions as trivial then we can construct nontrivial solutions $\bmod n$ for all $n$ having at least two prime factors, unless one of those factors is $2$ and has multiplicity $1$.
Describing all solutions should be very doable from here but would involve a slightly more tedious analysis $\bmod p^k$.
