IMO 1987 LL USS71

To every natural number k, k \geq2, there corresponds a sequence

IMO 1987 LL USS71

Origin: USS

Problem

To every natural number k, k \geq2, there corresponds a sequence an(k) according to the following rule: a0 = k, an = \tau(an−1) for n \geq1, in which \tau(a) is the number of different divisors of a. Find all k for which the sequence an(k) does not contain the square of an integer.