When teaching students about the Chinese remainder theorem, it is traditional to ask them questions like: "An integer $n$ is equivalent to $r_1 \bmod m_1$, to $r_2 \bmod m_2$ and to $r_3 \bmod m_3$. Compute $n \bmod m_1 m_2 m_3$." For example,
There are certain things whose number is unknown. If we count them by threes, we have two left over; by fives, we have three left over; and by sevens, two are left over. How many things are there? -- Sunzi Suanjing, 3rd century CE.
If it happens that $m_1 m_2 \equiv 1 \bmod m_3$, $m_1 m_3 \bmod m_2$ and $m_2 m_2 \bmod m_1$, then the question is particular easy to answer: One has $n = r_1 m_2 m_3 + r_2 m_1 m_3 + r_3 m_1 m_2$. I noticed this when preparing for my class today and planning to ask such a question with $(m_1, m_2, m_3) = (2,3,5)$, which has this property. Note that we can rewrite this property as $m_1 m_2 + m_1 m_3 + m_2 m_3 \equiv 1 \bmod m_1 m_2 m_3$.
So, for the fun of it, here is my question:
Can we describe all $k$-tuples of integers $(m_1, m_2, \ldots, m_k)$ such that $$m_1 m_2 \cdots m_{j-1} m_{j+1} \cdots m_k \equiv 1 \bmod m_j$$ for $1 \leq j \leq k$?
The trick is nice, but I am afraid it is hard to find any tuples, except for (2,3,5).
I tried brute force with 3 mods. For mods below 1000, only (2,3,5) satisfied.
However, even if you have only 1 pair that has $m_1\,m_2 \bmod m_3 = ±1$, it helps.
Example, $x ≡ a \bmod 5, x ≡ b \bmod 7, x ≡ c \bmod 9$
Since $5\times7 = 4\times9 - 1$, do mod 9 last.
Let $x'$ be 1 solution to $x ≡ a \bmod 5, x ≡ b \bmod 7$
$x' = a + 5k' ≡ a - 2k' ≡ b \bmod 7$
$k' = 2^{-1}(a - b) \bmod 7$
We leave $2^{-1} \bmod 7$ un-evaluated. You'll see why later ...
Let $x''$ be 1 solution to all three mods
$x'' = x' + 35k'' ≡ x' - k'' ≡ c \bmod 9$
$k'' = x' - c$
$x'' = x' + 35(x'-c) = 18(2x') - 35c = 18(2a + 5(a-b)) - 35c = 126a-90b-35c$
No inverse calculations were needed !
$$x ≡ x'' ≡ 126a-90b-35c \bmod 315$$