Euler's totient function #
This file defines Euler's totient function
nat.totient n
which counts the number of naturals less than n
that are coprime with n
.
We prove the divisor sum formula, namely that n
equals φ
summed over the divisors of n
. See
sum_totient
. We also prove two lemmas to help compute totients, namely totient_mul
and
totient_prime_pow
.
Euler's totient function. This counts the number of naturals strictly less than n
which are
coprime with n
.
Equations
- n.totient = (finset.filter n.coprime (finset.range n)).card
theorem
nat.totient_eq_card_coprime
(n : ℕ) :
n.totient = (finset.filter n.coprime (finset.range n)).card
theorem
nat.filter_coprime_Ico_eq_totient
(a n : ℕ) :
(finset.filter a.coprime (finset.Ico n (n + a))).card = a.totient
theorem
nat.Ico_filter_coprime_le
{a : ℕ}
(k n : ℕ)
(a_pos : 0 < a) :
(finset.filter a.coprime (finset.Ico k (k + n))).card ≤ (a.totient) * (n / a + 1)
theorem
nat.sum_totient
(n : ℕ) :
∑ (m : ℕ) in finset.filter (λ (_x : ℕ), _x ∣ n) (finset.range n.succ), m.totient = n
Euler's product formula for the totient function #
We prove several different statements of this formula.