RMM 2015 /P1: Does there exist an infinite sequence of positive integers $a_1, a_2, a_3, . . .$ Does there exist an infinite sequence of positive integers $a_1, a_2, a_3, . . .$ such that $a_m$ and $a_n$ are coprime if and only if $|m - n| = 1$?
My Progress:This is a very beautiful problem ! I think I have got a construction , but I am not able to  have/define the explicit formula for the nth term.
Here is the construction, Let $a_1=2\cdot 3$, $a_2=5\cdot 7$, $a_3=2\cdot 11$, $a_4=3\cdot 5 \cdot 13$, $a_5=2\cdot 7\cdot 17$ , $a_6=3\cdot 5 \cdot 11 \cdot 19$ , $a_7=2\cdot7\cdot13\cdot23$,  $a_8=3\cdot5\cdot11\cdot17\cdot29$ , $a_9=2\cdot7\cdot13\cdot 19 \cdot 31$ and so on .
I am trying to find some patterns, but I am not able to observe anything.
So what I am doing is, for the construction of $a_n$ term, I look at $a_{n-1}$ ,then I start from $a_1$ and then try to put a factor $p$  of $a_1$ in $a_n$ such that gcd ($a_{n-1},p$)=$1$ . Similarly for $a_2$, $a_3$, and so on. At the end I add another prime which was not used in any of the $a_i$'s. Also we have to make sure that no ${a_i} \mid a_j$ for $i<j$
Also note that I am only using primes .
Sorry, if something is not clear. Hope one can provide me some hints and guide.
Thanks in advance.
 A: By using the canonical indexing of primes, it is sufficient to show that there exists a sequence $\{A_n\}_{n\geq 1}$ of finite subsets of $\mathbb{N}\setminus\{0\}$ such that $A_{n+1}$ belongs to the complement of $A_n$ but has a non-trivial intersection with every member of the family $A_1,A_2,\ldots,A_{n-1}$. Your sequence is associated to
$$ \{1,2\},\{3,4\},\{1,5\},\{2,3,6\},\{1,4,7\},\{2,3,5,8\},\{1,4,6,9\},\{2,3,5,7,10\},\ldots$$
and I can see a pattern here: starting with $A_5=\{1,4,7\}$, $A_n$ is given by
$$ (A_{n-2}\setminus\{\max A_{n-2}\})\cup\{\max A_{n-2}-1\}\cup\{n+2\}. $$
 Decrease by one the maximum element of $A_{n-2}$, then append $n+2$.
By induction it should not be difficult to prove that this actually works. I'll start the proof:

*

*$A_n\cap A_{n+1}=\emptyset$. This is blatantly true for any $n\leq 6$, hence we may assume $n>6$. Since $\max A_{n+1}=n+3>n+2=\max A_n$, $\max A_{n+1}$ is not an element of $A_n$. The set $A_{n+1}\setminus\{\max A_{n+1}\}$ equals $A_{n-1}$ with the maximum element ($n+1$) being replaced by $n$. $A_n\cap A_{n-1}=\emptyset$ by inductive hypothesis, hence the proof of $A_n\cap A_{n+1}=\emptyset$ boils down to the proof of $n\not\in A_n$, which follows from $\max(A_n\setminus\{\max A_n\})=n-1$.

*$A_n$ has a non-trivial intersection with $A_1,A_2,\ldots,A_{n-2}$. By direct inspection we may assume $n>6$ as well. By definition $A_n$ has non-trivial intersections with $A_{n-2},A_{n-4},\ldots,A_2$, so it is sufficient to prove that $A_n$ has non-trivial intersections with $A_{n-3},A_{n-5},\ldots,A_1$. In the previous point we have shown $\max(A_n\setminus\{\max A_n\})=n-1=\max A_{n-3}$, so $A_n\cap A_{n-3}\neq\emptyset$. In a similar way we may show that if we remove the two greatest elements from $A_n$, the maximum becomes the maximum of $A_{n-5}$, so $A_n\cap A_{n-5}\neq \emptyset$ etcetera.

This is basically the reverse approach of the one taken by Eigen von Eitzen here (his sets end with $2n-1,2n$, our sets start with $1,4$ or $2,3$). We gain a pleasant bit of regularity if we pick $A_3$ as $\{2,5\}$ instead of $\{1,5\}$:
$$ \{1,2\},\{3,4\},\{2,5\},\{1,3,6\},\{2,4,7\},\{1,3,5,8\},\{2,4,6,9\},\{1,3,5,7,10\},\ldots$$
A: We'll do an inductive process, defining $a_{i,j}$ for integers $i \ge 1$ and $j \ge 0$.
Let $p_n$ be the $n$'th prime.
Initially, take $a_{1,1}= p_1 p_2 $, $a_{2,1} = 1$, $a_{n,1} = p_1$ if $n \ge 3$ is odd and $p_2$ if $n \ge 4$ is even.  Note that $a_{n,1}$ and $a_{n+1,1}$ are coprime, and $a_{1,1}$ and $a_{n,1}$ are not coprime for $n \ge 3$.  Suppose at stage $k$, all $a_{n,k}$ and $a_{n+1,k}$ are coprime, $a_{i,k}$ and $a_{j,k}$ are not coprime for $i \le k$ and $j \ge i+2$, and all prime factors of the $a_{n,k}$ are in the first $2k$ primes.  Let
$a_{k+1,k+1} = a_{k+1,k} p_{2k+1} p_{2k+2}$, $a_{n,k+1} = a_{n,k} p_{2k+1}$ if $n \ge k+3$ is even, $a_{n,k+1} = a_{n,k} p_{2k+2}$ if $n \ge k+3$ is odd, $a_{n,k+1} = a_{n,k}$ if $n < k$ or $n=k+1$.  Then we still have
$a_{n,k+1}$ and $a_{n+1,k+1}$ coprime, while $a_{i,k+1}$ and $a_{j,k+1}$ are not coprime for $i \le k+1$ and $j \ge i+2$, and all prime factors of the $a_{n,k+1}$ are in the first $2k+2$ primes.
Finally, take $a_n = a_{n,n}$.
