Problem

Source: 2022 Saudi Arabia IMO TST 1.1

Tags: number theory, divides, number theory with sequences, recurrence relation



Let $(a_n)$ be the integer sequence which is defined by $a_1= 1$ and $$ a_{n+1}=a_n^2 + n \cdot a_n \,\, , \,\, \forall n \ge 1.$$Let $S$ be the set of all primes $p$ such that there exists an index $i$ such that $p|a_i$. Prove that the set $S$ is an infinite set and it is not equal to the set of all primes.