Prove that there exist positive integers $a_1, a_2, …, a_n\ne 1$ such that $a_1a_2…\hat a_i…a_n \equiv 1 \pmod {a_i}$, for $i=1,2, …n$.

Let $n\ge 3$ be an integer. Prove that there exist positive integers $a_1, a_2, ..., a_n$ other than 1 such that $a_1a_2...\hat a_i...a_n \equiv 1 \pmod {a_i}$, for $i=1,2, ...n$. Here, $\hat a_i$ means the term $a_i$ is omitted.

I am having problems solving this question. I have tried small value since of $n$ up to 5 and honestly have no idea how to solve this rigorously. Help is appreciated thank you!

• Are you free to choose the $n$ integers or some of them are previously given? – Stefan4024 Jun 22 '16 at 16:21
• For $a_i \le 1000$, the only solution for $n=3$ is $2,3,5$ and for $n=4$ are $2,3,7,41$ and $2,3,11,13$. – lhf Jun 22 '16 at 16:56

$$a_1=2,\quad a_j=\left(\prod_{i=1}^{j-1}a_i\right)+1\ \ (j=2,3,\cdots, n-1),\quad a_n=\left(\prod_{i=1}^{n-1}a_i\right)-1$$ works since, in mod $a_i$ where $i=1,2,\cdots, n-1$, \begin{align}a_1a_2\cdots a_{i-1}a_{i+1}\cdots a_n&\equiv a_1a_2\cdots a_{i-1}\cdot1\cdot 1\cdots1\cdot (-1)\\&\equiv -a_1a_2\cdots a_{i-1}\\&\equiv -(a_i-1)\\&\equiv 1\end{align} and, in mod $a_n$, $$a_1a_2\cdots a_{n-1}\equiv a_n+1\equiv 1.$$
• I was thinking along the same line, but didn't know how to deal with the case $a_1,$ as I forgot $-1\equiv1\pmod2.$ Nice answer! – awllower Jun 22 '16 at 16:49
• @WilliamKin: By trial and error, I got $2,3,5$ for $n=3$, and $2,3,7,41$ for $n=4$. For $n=5$, I set the five numbers as $p,q,r,s,pqrs-1$. Then, I noticed that $s=pqr+1,r=pq+1,q=p+1$ work. Finally, we have to have $-1\equiv 1\pmod p$, from which we have $p=2$. So, I reached the construction I wrote in my answer. – mathlove Jun 23 '16 at 4:12