Problem

Source: Azerbaijan Math Olympiad Training

Tags: number theory, TST



Define a sequence ${{a_n}}_{n\ge1}$ such that $a_1=1$ , $a_2=2$ and $a_{n+1}$ is the smallest positive integer $m$ such that $m$ hasn't yet occurred in the sequence and also $gcd(m,a_n)\neq{1}$. Show that all positive integers occur in the sequence.