Problem

Source: Tournament of Towns, Fall 2002, Senior A Level, P6

Tags: number theory, greatest common divisor, number theory proposed



Define a sequence $\{a_n\}_{n\ge 1}$ 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 $\text{gcd}(m,a_n)\neq 1$. Show all positive integers occur in the sequence.