The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V02. Numbers

Mathlib.Data.Nat.Digits.Div

9 declarations. Mathlib docs · Source

Divisibility tests for natural numbers in terms of digits.

We prove some divisibility tests based on digits, in particular completing Theorem #85 from https://www.cs.ru.nl/~freek/100/.

Divisibility

theorem Nat.modEq_three_digits_sum E1 #

∀ (n : ℕ), n ≡ (Nat.digits 10 n).sum [MOD 3]

theorem Nat.modEq_nine_digits_sum E1 #

∀ (n : ℕ), n ≡ (Nat.digits 10 n).sum [MOD 9]

theorem Nat.modEq_eleven_digits_sum E1 #

∀ (n : ℕ), ↑n ≡ (List.map (fun n ↦ ↑n) (Nat.digits 10 n)).alternatingSum [ZMOD 11]

theorem Nat.dvd_iff_dvd_digits_sum E1 #

∀ (b b' : ℕ), b' % b = 1 → ∀ (n : ℕ), b ∣ n ↔ b ∣ (b'.digits n).sum

theorem Nat.three_dvd_iff E3 #

∀ (n : ℕ), 3 ∣ n ↔ 3 ∣ (Nat.digits 10 n).sum

Divisibility by 3 Rule

theorem Nat.nine_dvd_iff E0 #

∀ (n : ℕ), 9 ∣ n ↔ 9 ∣ (Nat.digits 10 n).sum

theorem Nat.dvd_iff_dvd_ofDigits E1 #

∀ (b b' : ℕ) (c : ℤ), ↑b ∣ ↑b' - c → ∀ (n : ℕ), b ∣ n ↔ ↑b ∣ Nat.ofDigits c (b'.digits n)

theorem Nat.eleven_dvd_iff E0 #

∀ {n : ℕ}, 11 ∣ n ↔ 11 ∣ (List.map (fun n ↦ ↑n) (Nat.digits 10 n)).alternatingSum

theorem Nat.eleven_dvd_of_palindrome E1 #

∀ {n : ℕ}, (Nat.digits 10 n).Palindrome → Even (Nat.digits 10 n).length → 11 ∣ n