In the following, if a and b are integers, then a | b means that b is divisible by a. Also, ℕ is the set of (positive) natural numbers, ℕ = {1, 2, 3, 4, …}, and ℕ_0 is equal to {0, 1, 2, 3, …} = ℕ ∪ {0}.
Theorem: ∀ N, d, k, r, a_0, ..., a_r ∈ ℕ_0 :
((N ≥ 2) ∧ (d ≥ 2)∧ (k ≥ 1) ∧ (d^k = N – 1) ∧ (0 ≤ a_0, ..., a_r ≤ N – 1) ⇒
(d | (a_r * N^r + … + a_1 * N^1 + a_0 * N^0) ⇔ d | (a_r + … + a_1 + a_0)))
Proof: Let N, d, k, r, a_0, ..., a_r ∈ ℕ_0 be such that N ≥ 2 and d ≥ 2 and k ≥ 1 and d^k = N – 1 and 0 ≤ a_0, ..., a_r ≤ N – 1 and otherwise arbitrary.
For all j ∈ ℕ,
d * (d^(k – 1)) * (N^(j – 1) + … + N^2 + N + 1) + 1
= (d^k) * (N^(j – 1) + … + N^2 + N + 1) + 1
= (N – 1) * (N^(j – 1) + … + N^2 + N + 1) + 1
= (N – 1) * N^(j – 1) + … + (N – 1) * N^2 + (N – 1) * N + (N – 1) + 1
= (N – 1) * N^(j – 1) + … + (N – 1) * N^2 + (N – 1) * N + N
= N * ((N – 1) * N^(j – 2) + … + (N – 1) * N + (N – 1) + 1)
= N * ((N – 1) * N^(j – 2) + … + (N – 1) * N + N)
= N^2 * ((N – 1) * N^(j – 3) + … + (N – 1) + 1)
= …
= N^(j – 1) * ((N – 1) * N^(j – j) + 1)
= N^(j – 1) * ((N – 1) * 1 + 1)
= N^(j – 1) * N
= N^j,
from which it follows that
(N^j) mod d
= (d * (d^(k – 1)) * (N^(j – 1) + … + N^2 + N + 1) + 1) mod d
= (d mod d) * (((d^(k – 1)) * (N^(j – 1) + … + N^2 + N + 1)) mod d) + (1 mod d)
= 0 + 1 because d mod d = 0 and 1 mod d = 1 due to d > 1,
= 1 (equation 1).
Thus, we obtain the following:
d | (a_r * N^r + … + a_1 * N^1 + a_0 * N^0)
⇔ 0 = (a_r * N^r + … + a_1 * N + a_0 * 1) mod d
= ((a_r * N^r) mod d) + … + ((a_1 * N) mod d) + (a_0 mod d)
= (a_r mod d)*(N^r mod d) + … + (a_1 mod d)*(N mod d) + (a_0 mod d)
= (a_r mod d)*1 + … + (a_1 mod d)*1 + (a_0 mod d) because of equation (1),
= (a_r + … + a_1 + a_0) mod d
⇔ d | (a_r + … + a_1 + a_0). Q.E.D
If we substitute N = 10, d = 9 and k = 1 in the above theorem, we find that a natural number m = a_r * 10^r + … + a_1 * 10 + a_0 is divisible by 9 if and only if the sum of its digits a_r + … + a_1 + a_0 is divisible by 9.
If we substitute N = 10, d = 3 and k = 2 in the above theorem, we find that a natural number m = a_r * 10^r + … + a_1 * 10 + a_0 is divisible by 3 if and only if the sum of its digits a_r + … + a_1 + a_0 is divisible by 3.
As can be seen, there is nothing mysterious about this quite useful result, which we have shown to be true for every base greater than or equal to 2 and every number that has a power equal to that base – 1.
-- Updated January 10th, 2017, 5:39 pm to add the following --
Philosophy Explorer wrote: I challenge anyone to find an exception. Test it out on your computers and scientific calculators.
Still, you have to prove your assertion. Otherwise, it may turn out to be false for some really large numbers. In mathematics and logic, proofs must be that – proofs, not just assumptions based on empirical evidence. Experimentation should only be used to find candidates for new theorems or to find counterexamples to conjectures.