MathorynMathematical Formula Database

Number Theory

Euler's Totient Function

Euler's totient φ(n)\varphi(n) counts the integers from 1 to nn that are coprime to nn. It is a key ingredient of RSA encryption and Euler's theorem.

φ(n)=n∏p∣n(1−1p)\varphi(n)=n\prod_{p\mid n}\left(1-\frac{1}{p}\right)
LaTeX\varphi(n)=n\prod_{p\mid n}\left(1-\frac{1}{p}\right)

Variables

φ(n)\varphi(n)
count of integers 1..n coprime to n
pp
distinct prime divisors of n

Example

Find φ(36)\varphi(36).

  1. Primes dividing 36: 2,32,3.
  2. 36⋅12⋅2336\cdot\frac12\cdot\frac23.

Answer: 1212.

Related formulas