phi-phi-phi
Practice
3.5 (15 votes)
Easy
Euler's totient function
Math
Number theory
Problem
91% Success 8060 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code
Given n and k, calculate \(\varphi(\varphi(...\varphi(n)...))\), where \(\varphi\) applied exactly k times.
\(\varphi(n)\) is Euler's totient function. \(\varphi(1)=1\) by definition.
You can find the definition of Euler's totient function here.
Input format
The only line of input contains two integers n and k (\(1 \le n \le 10^{18}\), \(1 \le k \le 10^{18}\)).
Output format
Print one integer - answer to the problem.
Scoring
\(n \le 10^{3}\), \(k \le 10^{3}\) - 10 points
\(n \le 10^{6}\), \(k \le 10^{18}\) - 15 points
\(n \le 10^{12}\), \(k = 1\) - 10 points
\(n \le 10^{12}\), \(k \le 10^{18}\) - 10 points
\(n \le 10^{15}\), \(k = 1\) - 5 points
\(n \le 10^{15}\), \(k \le 10^{18}\) - 40 points
\(n \le 10^{18}\), \(k \le 10^{18}\) - 10 points
Submissions
Please login to view your submissions
Similar Problems
Points:20
13 votes
Tags:
AlgebraEasyEuler's totient functionMathNumber Theory
Points:20
38 votes
Tags:
ApprovedEasyEuler's totient functionMathOpen
Editorial