Euler's totient function
![The first thousand values of φ(n). The points on the top line represent φ(p) when p is a prime number, which is p − 1.[1]](/uploads/202501/12/EulerPhi.svg0735.png)

In number theory, Euler's totient function counts the positive integers up to a given integer n that are relatively prime to n. It is written using the Greek letter phi as φ(n) or ϕ(n), and may also be called Euler's phi function. It can be defined more formally as the number of integers k in the range 1 ≤ k ≤ n for which the greatest common divisor gcd(n, k) = 1; The integers k of this form are sometimes referred to as totatives of n.