Divisibility Rules Practice & Multi-Tester
Test any integer against all divisibility rules from 2 through 13 simultaneously with real-time modular arithmetic step-by-step proofs.
Comprehensive Theory of Divisibility & Modular Arithmetic
Master number-theoretic divisibility definitions, algebraic modular proofs for 3, 7, 9, and 11, composite coprime factorization, and check-digit error detection algorithms.
1. Number Theory Foundations & Modular Congruence
In elementary and higher arithmetic, divisibility is a fundamental algebraic relationship between two integers. Formally, an integer $b$ is said to be divisible by a non-zero integer $a$ (written in number theory as $a \mid b$, pronounced "$a$ divides $b$") if and only if there exists some integer $k \in \mathbb{Z}$ such that:
When dividing $b$ by $a$ via the Division Algorithm, the remainder $r$ satisfies $b = q \cdot a + r$, with $0 \le r < |a|$. Divisibility holds when the remainder $r = 0$.
Divisibility shortcuts are derived from modular arithmetic, introduced by Carl Friedrich Gauss in his 1801 treatise Disquisitiones Arithmeticae. Two numbers are congruent modulo $m$ (written $x \equiv y \pmod m$) if their difference $(x - y)$ is an exact integer multiple of $m$. Every integer in base 10 can be expanded as a polynomial in powers of 10:
By evaluating the polynomial coefficients $10^k \pmod m$, mathematicians derive elegant tests that verify divisibility without computing full long division quotients.
2. Algebraic Derivations & Modular Proofs for Core Rules
Every standard divisibility rule is a direct theorem of modular congruence:
1. Proof of the Digit Sum Rule for 3 and 9
Notice that $10 = 9 + 1 \equiv 1 \pmod 9$ and $10 \equiv 1 \pmod 3$. By the properties of modular multiplication, any power of 10 satisfies $10^k \equiv 1^k \equiv 1 \pmod 9$ (and $\pmod 3$). Substituting this into the polynomial expansion of $N$:
N ≡ dₙ(1) + ... + d₁(1) + d₀ ≡ (dₙ + ... + d₁ + d₀) (mod 9)
Thus, $N$ leaves the exact same remainder when divided by 9 as the sum of its individual digits. If the digit sum is a multiple of 9 (or 3), $N$ is divisible by 9 (or 3).
2. Proof of the Last Digits Rule for Powers of 2 and 5 (2, 4, 8, 5, 10)
Because the base $10 = 2 \times 5$, higher powers of 10 contain factors of $2^k$ and $5^k$:
- $10 \equiv 0 \pmod 2$ and $10 \equiv 0 \pmod 5$: All terms above the units place are multiples of 2 and 5. Hence, divisibility depends strictly on the final single digit $d_0$.
- $100 = 10^2 = 4 \times 25 \equiv 0 \pmod 4$: All terms above the tens place are multiples of 4. Hence, divisibility by 4 depends strictly on the last two digits ($10 d_1 + d_0$).
- $1,000 = 10^3 = 8 \times 125 \equiv 0 \pmod 8$: All terms above hundreds are multiples of 8. Divisibility by 8 depends strictly on the last three digits.
3. Proof of the Alternating Sum Rule for 11
Observe that $10 = 11 - 1 \equiv -1 \pmod{11}$. Therefore, powers of 10 alternate in sign:
Substituting into the decimal expansion yields:
If the alternating sum $(d_0 + d_2 + d_4 + \dots) - (d_1 + d_3 + d_5 + \dots)$ is 0 or a multiple of 11, then $N$ is divisible by 11.
4. Proof of the Truncation Test for 7
Let a number be written as $N = 10a + b$, where $b$ is the units digit and $a$ is the truncated leading number. We seek to eliminate the factor of 10 modulo 7. Since $\gcd(10, 7) = 1$, the modular inverse of 10 mod 7 is $-2$ (because $10 \times (-2) = -20 \equiv 1 \pmod 7$). Multiplying $N$ by $-2$:
This proves that $10a + b$ is divisible by 7 if and only if $a - 2b$ (the remaining number minus twice the units digit) is divisible by 7.
3. Master Reference Table: Divisibility Rules from 2 to 19
| Divisor | Divisibility Test Criterion | Worked Verification Example |
|---|---|---|
| 2 | Last digit is even ($0, 2, 4, 6, 8$). | 1,438 → ends in 8 → Divisible |
| 3 | Sum of all digits is divisible by 3. | 471 → 4+7+1 = 12 ($12 \div 3 = 4$) → Divisible |
| 4 | Last two digits form a number divisible by 4. | 1,324 → 24 is divisible by 4 → Divisible |
| 5 | Last digit is strictly 0 or 5. | 9,875 → ends in 5 → Divisible |
| 6 | Divisible by both 2 (even) AND 3 (digit sum). | 792 → even and 7+9+2=18 (div by 3) → Divisible |
| 7 | Subtract twice the last digit from the rest: $a - 2b$. Result is div by 7. | 672 → $67 - (2 \times 2) = 63$ ($63 \div 7 = 9$) → Divisible |
| 8 | Last three digits form a number divisible by 8. | 5,128 → $128 \div 8 = 16$ → Divisible |
| 9 | Sum of all digits is divisible by 9. | 2,853 → 2+8+5+3 = 18 ($18 \div 9 = 2$) → Divisible |
| 10 | Last digit is strictly 0. | 4,590 → ends in 0 → Divisible |
| 11 | Alternating sum of digits is 0 or multiple of 11. | 2,728 → (2+2) - (7+8) = -11 → Divisible |
| 12 | Divisible by both 3 (sum) AND 4 (last 2 digits). | 648 → 6+4+8=18 (div by 3) and 48 (div by 4) → Divisible |
| 13 | Add 4 times the last digit to the rest: $a + 4b$. Result is div by 13. | 637 → $63 + (4 \times 7) = 91$ ($91 \div 13 = 7$) → Divisible |
| 17 | Subtract 5 times the last digit from the rest: $a - 5b$. Result is div by 17. | 476 → $47 - (5 \times 6) = 17$ → Divisible |
4. Step-by-Step Worked Case Studies with Complete Arithmetic
Case Study 1: Multi-Rule Battery on Cyclic Number 142,857
Scenario: Test the famous repeating decimal cycle $N = 142,857$ across the primary divisors:
- Divisible by 2? Last digit is 7 (odd) → Not Divisible.
- Divisible by 3? Digit sum = $1 + 4 + 2 + 8 + 5 + 7 = 27$. Since $27 \div 3 = 9$ → Divisible ($142,857 \div 3 = 47,619$).
- Divisible by 7? Truncation test: $14,285 - 2(7) = 14,271 \rightarrow 1,427 - 2(1) = 1,425 \rightarrow 142 - 2(5) = 132 \rightarrow 13 - 2(2) = 9$. Wait: let's do direct modular division: $142,857 \div 7 = 20,408.14$. But $142,857 \times 7 = 999,999$! Notice $999,999$ is divisible by 7 ($999,999 / 7 = 142,857$), so $142,857$ itself is NOT divisible by 7!
- Divisible by 9? Digit sum is 27. Since $27 \div 9 = 3$ → Divisible ($142,857 \div 9 = 15,873$).
- Divisible by 11? Alternating sum: $(7 + 8 + 4) - (5 + 2 + 1) = 19 - 8 = 11$. Since 11 is a multiple of 11 → Divisible ($142,857 \div 11 = 12,987$).
- Divisible by 13? $142,857 \div 13 = 10,989$ → Divisible.
Case Study 2: Recursive Truncation Test for 7 on 37,429
Goal: Determine if $N = 37,429$ is divisible by 7 using the $a - 2b$ algorithm without performing division.
- Truncate last digit (9): $3,742 - (2 \times 9) = 3,742 - 18 = 3,724$.
- Truncate last digit (4): $372 - (2 \times 4) = 372 - 8 = 364$.
- Truncate last digit (4): $36 - (2 \times 4) = 36 - 8 = 28$.
- Evaluate: $28$ is an obvious multiple of 7 ($28 = 4 \times 7$).
Conclusion: $37,429$ is strictly divisible by 7 ($37,429 \div 7 = 5,347$).
Case Study 3: Composite Divisibility Verification for 12 and 36
Scenario: Check if $N = 10,584$ is divisible by 12 and 36.
Step 1: Test for 12 ($\gcd(3, 4) = 1$):
- Sum of digits: $1 + 0 + 5 + 8 + 4 = 18$ ($18 \div 3 = 6$) → Divisible by 3.
- Last two digits: $84$ ($84 \div 4 = 21$) → Divisible by 4.
- Since $10,584$ is divisible by both 3 and 4, it is divisible by 12 ($10,584 \div 12 = 882$).
Step 2: Test for 36 ($\gcd(4, 9) = 1$):
- Divisible by 4: Yes (last two digits 84).
- Divisible by 9: Digit sum is 18 ($18 \div 9 = 2$) → Divisible by 9.
- Since $10,584$ is divisible by both 4 and 9, it is divisible by 36 ($10,584 \div 36 = 294$).
5. Cryptographic, Financial & Data Integrity Applications
Divisibility and modular arithmetic rules form the foundation of global data verification protocols:
- Credit Card Validation (The Luhn Algorithm): Standard payment card numbers (Visa, Mastercard, Amex) encode a check digit validated using a modified modulo-10 divisibility algorithm (ISO/IEC 7812-1). Doubling every second digit from right to left and summing the digits must produce a total divisible by 10, instantly blocking accidental typos before transmitting transactions.
- Book Publishing & ISBN-10 Checksums: International Standard Book Numbers (ISBN-10) employ a weighted modulo-11 divisibility rule: $\sum_{i=1}^{10} (11 - i) \cdot x_i \equiv 0 \pmod{11}$. Because 11 is prime, this rule provides mathematical protection against both single-digit typing errors and two-digit transposition slips. If the check digit equals 10, the letter "X" is inscribed.
- Computer Systems & Fast Bitwise Arithmetic: In low-level software engineering, checking divisibility by powers of 2 ($2, 4, 8, 16, 32$) avoids expensive CPU division cycles. Compilers replace $x \pmod{2^k} == 0$ with ultra-fast bitwise masks:
(x & ((1 << k) - 1)) == 0.
6. Common Conceptual Traps & Calculation Pitfalls
Avoid these common fallacies when applying divisibility shortcuts:
- The Non-Coprime Factor Trap: You can only test a composite divisor by checking its factors if those factors are coprime ($\gcd(a, b) = 1$). For example, testing divisibility by 12 using 2 and 6 is a fallacy: the number 18 is divisible by 2 and divisible by 6, but $18 \div 12 = 1.5$ (not divisible!). For 12, one must test 3 and 4 ($\gcd(3, 4) = 1$). Similarly, for 24, test 3 and 8 (not 4 and 6).
- The Zero Divisibility Fallacy: Students frequently ask if 0 is divisible by 7. By definition, $0 = 0 \times 7$, so 0 is divisible by every non-zero integer. However, division by zero ($7 \div 0$) is mathematically undefined.
- Assuming the Digit Sum Rule Works for All Numbers: The digit sum rule works only for 3 and 9 in base 10 because $10 \equiv 1 \pmod 3$ and $10 \equiv 1 \pmod 9$. Summing digits does not test divisibility for 4, 6, 7, or 8.
7. Frequently Asked Questions (FAQ)
Why does the digit sum rule work for divisibility by 3 and 9?
In base 10, every power of 10 leaves a remainder of 1 when divided by 9 or 3 (because $10 \equiv 1 \pmod 9$, $100 \equiv 1 \pmod 9$, and $10^n \equiv 1 \pmod 9$). Therefore, expanding a number $N = d_n \cdot 10^n + \dots + d_0$ modulo 9 simplifies directly to $N \equiv d_n + \dots + d_0 \pmod 9$. A number is divisible by 9 (or 3) if and only if the sum of its digits is divisible by 9 (or 3).
How does the divisibility test for 7 work algebraically?
To test if $10a + b$ is divisible by 7, multiply by $-2$ (the modular inverse of 10 mod 7): $-2(10a + b) = -20a - 2b \equiv a - 2b \pmod 7$. Thus, double the last digit ($2b$) and subtract it from the truncated leading number ($a$). If the resulting difference is divisible by 7 or equals 0, the original number is divisible by 7.
Why does the alternating sum rule test for divisibility by 11?
Because $10 \equiv -1 \pmod{11}$, powers of 10 alternate between $+1$ and $-1$ modulo 11: $10^0 \equiv 1$, $10^1 \equiv -1$, $10^2 \equiv 1$, $10^3 \equiv -1$, etc. Therefore, a decimal number modulo 11 equals its alternating sum of digits: $(d_0 + d_2 + d_4 + \dots) - (d_1 + d_3 + d_5 + \dots)$. If this difference is 0 or any integer multiple of 11, the number is divisible by 11.
How do you test divisibility for composite numbers like 6, 12, 15, and 36?
A number is divisible by a composite divisor if and only if it is divisible by each of its coprime factors (factors whose greatest common divisor is 1). For example, $12 = 3 \times 4$ ($\gcd(3,4)=1$), so a number divisible by both 3 and 4 is divisible by 12. You cannot use 2 and 6 for 12 because $\gcd(2,6)=2$, which would incorrectly classify 18 as divisible by 12.
How are divisibility rules applied in check digit algorithms like credit cards and barcodes?
Financial credit cards use the Luhn Algorithm (modulo 10 checksum), while ISBN-10 book codes use a weighted modulo 11 checksum. By appending a mathematically computed terminal check digit such that the entire sequence satisfies a modular divisibility equation, automated scanners instantly detect typographical single-digit entry errors and digit transposition slips.