Skip to content
← All questions

What is the general formula for Euler's totient function?

The general formula for Euler's totient function is φ(n)=n∏i=1m(1−1pi)\varphi(n) = n \prod_{i=1}^{m} \left(1 - \frac{1}{p_i}\right), where p1,p2,…,pmp_1, p_2, \ldots, p_m are the distinct prime factors of nn. This formula is derived by combining the multiplicativity of φ\varphi, the prime power formula φ(pk)=pk−pk−1\varphi(p^k) = p^k - p^{k-1}, and the Fundamental Theorem of Arithmetic.

Conditions

  • nn is a positive integer greater than 1.
  • p1,…,pmp_1, \ldots, p_m are all the distinct prime factors of nn.

Reasoning, step by step

  1. Start with the prime factorization of nn: n=p1k1p2k2⋯pmkmn = p_1^{k_1} p_2^{k_2} \cdots p_m^{k_m}.
  2. Use the multiplicativity of φ\varphi to write φ(n)=φ(p1k1)φ(p2k2)⋯φ(pmkm)\varphi(n) = \varphi(p_1^{k_1}) \varphi(p_2^{k_2}) \cdots \varphi(p_m^{k_m}).
  3. Substitute the prime power formula φ(pk)=pk−pk−1\varphi(p^k) = p^k - p^{k-1} for each factor.
  4. Factor out pikip_i^{k_i} from each term: piki−piki−1=piki(1−1/pi)p_i^{k_i} - p_i^{k_i-1} = p_i^{k_i}(1 - 1/p_i).
  5. Multiply all the factored terms together: φ(n)=(p1k1⋯pmkm)∏i=1m(1−1/pi)\varphi(n) = (p_1^{k_1} \cdots p_m^{k_m}) \prod_{i=1}^{m} (1 - 1/p_i).
  6. Recognize that p1k1⋯pmkm=np_1^{k_1} \cdots p_m^{k_m} = n, yielding the final formula φ(n)=n∏i=1m(1−1/pi)\varphi(n) = n \prod_{i=1}^{m} (1 - 1/p_i).
  7. Compress the product using product notation.

Example

For n=100n = 100, the distinct prime factors are 2 and 5. Using the formula: φ(100)=100(1−12)(1−15)=100⋅12⋅45=40\varphi(100) = 100 \left(1 - \frac{1}{2}\right) \left(1 - \frac{1}{5}\right) = 100 \cdot \frac{1}{2} \cdot \frac{4}{5} = 40.

Common misconceptions

  • Including repeated prime factors in the product (the product is over DISTINCT prime factors).
  • Forgetting to multiply by nn at the beginning of the formula.
  • Confusing the general formula with the specific prime power formula φ(pk)=pk−pk−1\varphi(p^k) = p^k - p^{k-1}.

Watch the explanation

Explore next

Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.