For all positive integers \(n\), the totient function \(\phi (n)\) denotes the number of positive integers \(\leq n\) coprime to \(n\).

It turns out that if we apply the totient function successively on any positive integer \(n>1\), after finitely many operations we get the number \(1\). In other words, for all positive integers \(n>1\), there exists a positive integer \(m\) such that \(\underbrace{\phi ( \phi ( \phi ( \cdots \phi (n ) \cdots )))}_{m \text{ times}}= 1\).

For all \(n \in \mathbb{N}\), let \(f(n)\) denote the minimum number of times we need to apply the totient function successively on \(n\) to get the number \(1\). Find the last three digits of \(\displaystyle \sum \limits_{n=1}^{2014} f(n)\).

Consider the rectangular spiral in the image below. It starts from the origin and twirls and twirls forever in an anticlockwise direction along the integer coordinates of the Cartesian coordinate plane.Each point along the spiral is numbered with an integer \(Z\) as shown in the image below.

What is the value of the integer \(Z\) at the coordinate \((12,-22)\)?

Details and assumptions

As an explicit example \(Z\) is \(10\) for \((2,0)\) , \(3\) for \((0,1)\) and \(10\) for \((2,0)\).

Excel in math and science

Master concepts by solving fun, challenging problems.

It's hard to learn from lectures and videos

Learn more effectively through short, conceptual quizzes.

Our wiki is made for math and science

Master advanced concepts through explanations,
examples, and problems from the community.

Used and loved by 4 million people

Learn from a vibrant community of students and enthusiasts,
including olympiad champions, researchers, and professionals.