# PARI/GP practice #2

**Computer Science**Level 4

Define the Collatz function \(c(n)\) as follows: if \(n\) is even, then \(c(n)=\frac{n}{2}\). If it is odd, then \(c(n)=3n+1\). Let \(a(n)\) be the least number of applications of the function \(c\) on \(n\) that is equal to \(1\). (For example, \(a(3)=8\) since 3 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 has length 8, and \(a(12)=10\) since 12 -> 6 -> 3 ->... -> 1 has length 10.) Let \(k\) be the concatenation of all positive integers up to and including \(1000\) (starts \(12345...\)). Find \(a(k)\).