Grand Unified Divisibility Rule

Every divisibility rule
is one single formula.

The digit-sum rule for 3, the alternating sum for 11, the last-digits trick for 4 and 8, the weighted rule for 7 — they are all rows of one table, produced by one algorithm that needs no prime factors and no division. Worked out in a Turkish high school in 1997, generalized and proven in 2026.

This is a rediscovery, not a discovery. The rule on this page is Pascal's divisibility criterion, described by Blaise Pascal in De numeris multiplicibus around 1654, and the 1997 equation belongs to a family of tests published by A. Zbikowski in 1861. Both were found here independently and without knowing they existed. Every claim is mapped to its published source in Prior Art.
1
formula for every divisor
0
prime factors needed
3
lines of proof
+ × −
the only operations used
The Story

A notebook, a calculator, and 29 years

This is not a textbook result. It is one person’s amateur discovery that slowly grew into a theorem — told in full in the project README.

1997

The discovery

A high school student in Izmir spends months with a basic calculator, hunting for an algorithm to detect prime numbers. The divisibility rules of numbers sharing the same last digit look alike — and that observation becomes one equation covering them all, mailed to TUBITAK as a math project. Nothing happens.

2021

The program

24 years later the old papers resurface and a program is written to validate the formula. It works — but only after factoring the divisor into primes first. The prime factorization step always felt like a workaround, never part of the idea.

2026

The generalization

The reason the workaround was needed finally becomes clear — a hidden constraint of the 1997 equation. Generalizing it removes the constraint: one rule for every divisor, with no factoring, no division, and a three-line proof.

2026

The literature search

Done properly at last, and it settles the question: Pascal had the generalized rule in 1654, Zbikowski had the 1997 equation's family in 1861, and O'Shea proved the two are the same rule in 2019. Twenty-nine years of private conviction, replaced by a map of the territory — and two things I had wrong, corrected.

The 1997 Discovery

The 1997 Equation

For a dividend N = 10·a1 + b1 and a divisor d = 10·a2 + b2, one equation generates the divisibility rule of any divisor from its digits alone:

Prior art. This is a trimming test, and the family it belongs to was published by A. Zbikowski in 1861. It is also exactly one member of the two-parameter family of Grinberg & Luryi (2014) — the member with the parameter hard-wired, which is what breaks the six rules below.
f(N) = (x · a1) + ((y · a2) + 1) · b1 where x = 10 + b2 − b2 · ⌈10 / b2⌉ and y = ⌈10 / b2⌉ − 1

Apply f to the dividend, then to the result, and keep going until the number is small. The 36 rules it produces for the divisors between 11 and 50 include familiar classics:

12valid
5 × last digit + 2 × remaining
13valid
4 × last digit + 1 × remaining
17valid
2 × last digit + 3 × remaining
23valid
7 × last digit + 1 × remaining
27broken
3 × last digit + 3 × remaining
45broken
5 × last digit + 5 × remaining

Six of the thirty-six rules — for 16, 18, 27, 36, 38 and 45 — looked exactly as trustworthy as the rest, but are subtly false. The equation is valid exactly when gcd((y·a2)+1, d) = 1, and factoring the divisor into primes first was silently repairing the cases where that fails. It is tempting to conclude that primes are special here. They are not: those six divisors have perfectly good rules in Grinberg & Luryi's table, reached by choosing the free parameter differently — for 16, 2B − 3b. The failures come from hard-wiring one coefficient, not from composite divisors. The full algebra is in the project README.

The Generalization

One rule, every divisor

The fix is not to patch the equation but to see what it really is, and run it in the other direction. The result works for every divisor — prime or composite, even or odd — using nothing but reading digits, small multiplications, and subtraction.

A number is divisible by d exactly when the weighted sum of its digits is divisible by d. The ones digit has weight 1; every next weight is the previous one times 10, then reduced below d by subtracting d. The final total is the exact remainder.
Prior art — this rule is Pascal's. The statement above is Pascal's divisibility criterion, from De numeris multiplicibus, written around 1654. Pascal's own words are that you may replace each power of ten by its remainder modulo D, and the resulting number “aura toujours même reste que A dans la division par D” — will always have the same remainder as A divided by D. The weights, the coverage of every divisor with no coprimality condition, the independence of the number base and the fact that the output is the remainder itself were all already there, 372 years ago.

Compute the weight row of a divisor and you get its divisibility rule. The famous rules stop being separate tricks and become rows of one table:

Divisor Weights (ones digit first) The classical rule it becomes
21, 0, 0, 0, …Even numbers — only the last digit decides, and it must be 0, 2, 4, 6 or 8.
31, 1, 1, 1, …The digit-sum rule — add every digit and the total must be divisible by 3.
41, 2, 0, 0, …The last-two-digits rule — the number formed by the tens and ones digits must be a multiple of 4.
71, 3, 2, 6, 4, 5, …The classical weighted rule for 7 — multiply the digits by 1, 3, 2, 6, 4, 5 from the right, repeating the cycle.
81, 2, 4, 0, 0, …The last-three-digits rule — the number formed by the last three digits must be a multiple of 8.
91, 1, 1, 1, …The digit-sum rule again — the digits must add up to a multiple of 9.
111, 10, 1, 10, …The alternating-sum rule — add and subtract the digits in turn, because 10 behaves as −1.
121, 10, 4, 4, …Divisible by 3 and by 4 at once — one weight row does the work of both.
201, 10, 0, 0, …Ends in 00, 20, 40, 60 or 80 — only the last two digits matter.
271, 10, 19, 1, 10, 19, …Split the digits into blocks of three from the right and add the blocks, because 1000 leaves remainder 1.
451, 10, 10, 10, …Divisible by 9 and by 5 — the digit sum is a multiple of 9 and the last digit is 0 or 5.

Divisors made only of 2s and 5s collapse their weights to 0 — that is why only the last few digits matter for them. Divisors sharing no factor with 10 cycle forever. Mixed divisors like 12 and 45 do a little of each. One mechanism, three behaviors.

The Proof

Three lines, no hand-waving

This is the standard proof of Pascal's criterion — the same induction found in any elementary number theory treatment — written out in the vocabulary of this page.

Subtracting d never changes a number’s remainder by d. So by induction, every weight has the same remainder as the power of ten it replaced: weight(t) ≡ 10t (mod d).

Therefore the weighted digit sum is congruent to digit(0)·100 + digit(1)·101 + … — which is the number N itself. The weighted sum ≡ N (mod d).

The running total is kept below d and stays congruent to N, so the final total is exactly the remainder of N divided by d. It is 0 exactly when d divides N. ∎

Prior Art

Everything above already existed

In July 2026, after all of the above had been written, a proper literature search finally happened. The result is unambiguous: every mathematical claim on this page already exists in the literature, some of it for centuries. Rather than quietly rewrite the page, here is the map — each claim next to its source, with the point of overlap named.

What this page presents Where it already exists Exactly how they overlap
The generalized rule: weights are the powers of ten reduced modulo d, and the weighted digit sum is congruent to N. Pascal, c. 1654 [P] Complete overlap. Pascal's criterion is “replace each power of 10 by its remainder mod D”. Same weights, same rule.
The final total is the exact remainder, not merely a yes/no signal — presented above as a bonus. Pascal, c. 1654 [P] Complete overlap. The remainder-preserving property is Pascal's original formulation, not something added on top of it.
The rule needs no coprimality condition and covers 2, 4, 8, 16, 20, 45 and every other divisor. Pascal [P]; binomial test [O] Complete overlap. a ≡ Σ (10 − q)j·aj (mod q) holds unconditionally for every q, which is why no coprimality hypothesis was ever needed.
Every classical rule — 2, 3, 4, 8, 9, 11 — is a row of one table. Grinberg & Luryi, 2014 [GL] Complete overlap. Their abstract says it outright: “Well-known divisibility rules for exemplary divisors in the decimal system follow from the universal expression as special cases.”
Weights of divisors built only from 2s and 5s collapse to 0; divisors coprime to 10 cycle; mixed divisors do both. Standard consequence [M] [W] Complete overlap. This is the textbook explanation of why the rules for 4 and 8 look only at the last digits.
The three-line proof. Standard proof [P] [M] Complete overlap. The three steps are the usual induction on 10t ≡ weight(t) (mod d).
The 1997 trimming equation (x·a1) + ((y·a2)+1)·b1. Zbikowski, 1861 [Z] [CM] Same family. Zbikowski's test is Tq(a) = ā + ωq·a0 with ωq = 10−1 mod q, for divisors ending in 1, 3, 7, 9 — the 1997 equation with the classical multiplier.
…and specifically as one member of a two-parameter family. Grinberg & Luryi, 2014 [GL] Exact identification, verified. Their restricted rule R = u·B + w·b is valid when N = 10w − u is a multiple of d. Substituting gives 10w − x = y·d, so the 1997 equation is their rule at q = y. Checked for every d from 2 to 99: zero mismatches.
The corrected multiplier table m for divisors ending in 1, 3, 7, 9. Zbikowski [Z]; osculators [V]; Kordemsky [Ko] Complete overlap. m = 10−1 mod d throughout — verified against pow(10, -1, d) for sixteen divisors. The m = 5 row is the classical positive osculator, and the ×5 walk for testing 7 is Kordemsky's problem 320.
The trimming rule and the weighted-sum rule are the same rule run in opposite directions. O'Shea, 2019 [O]; Khare, 1997 [K] Complete overlap; it is the paper's thesis. Theorem 2: (Stack ∘ Tq)n(a) = Sq(a). Theorem 3: (LStack ∘ LTq)n(a) = Bq(a). Trimming becomes summing, in both directions.
The trimming rule requires gcd(d, 10) = 1, which is why it cannot reach even divisors. Textbook [W] [S] [Pal] Complete overlap. Wikipedia states it directly: the rule “is really a rule for divisibility by any integer relatively prime to 10”.

What this project does add

With the above on the table, here is what appears to be genuinely original — stated small, because it is small.

  1. A closed form for the trimming coefficients, read off the divisor's last digit alone. x = 10 + b2 − b2·⌈10/b2⌉ and y = ⌈10/b2⌉ − 1. Zbikowski's ωq comes from a recipe and Grinberg & Luryi's (u, w) from a table; this is a formula in b2 needing neither. Not found in print — but a convenience, not a theorem.
  2. The exactness criterion for that parametrization. The identity f(N) = ((y·a2)+1)·N − (y·a1)·d, the criterion gcd((y·a2)+1, d) = 1, and the complete failure set below 100: 16, 18, 27, 36, 38, 45, 56, 57, 58, 76, 78, 87, 95, 96, 98. Verified two independent ways — by the criterion and by brute force — which agree exactly.
  3. An independent rediscovery in 1997, on paper, with a pocket calculator. Not a contribution to mathematics. Still the reason this project exists.
  4. The engineering and the pedagogy. A division-free implementation whose only operation on the divisor is subtraction, a full trace of every step, exhaustive verification over all 10,000 dividend/divisor pairs from 1 to 100, and this four-language visualization. Pascal's criterion is in every number theory book; a runnable, traceable, tested presentation of it is rarer.

References

If you need to cite the mathematics rather than this implementation, these are the citations you want.

  • [P] Pascal, B. De numeris multiplicibus ex sola characterum numericorum additione agnoscendis. Written c. 1654, presented to the Académie Parisienne in 1654, published 1665 in Traité du triangle arithmétique.
  • [Z] Zbikowski, A. (1861). Note sur la divisibilité des nombres. Bulletin de l'Académie impériale des sciences de St. Pétersbourg, Classe physico-mathématique, 3: 151–153.
  • [CM] Cherniavsky, Y., Mouftakhov, A. (2014). Zbikowski's Divisibility Criterion. The College Mathematics Journal 45(1): 17–21. doi:10.4169/college.math.j.45.1.017
  • [K] Khare, A. (1997). Divisibility Tests. Furman University Electronic Journal of Undergraduate Mathematics 3: 1–5. scholarexchange.furman.edu
  • [Pal] Pal, P. B. (2005). Divisibility tests with weighted digital sums. arXiv:math/0507011. arxiv.org/abs/math/0507011
  • [GL] Grinberg, A. A., Luryi, S. (2014). General Divisibility Criteria. arXiv:1401.5486. arxiv.org/abs/1401.5486
  • [M] McDowell, E. L. (2018). Divisibility Tests: A History and User's Guide. MAA Convergence, May 2018. old.maa.org
  • [O] O'Shea, E. (2019). Divisibility Tests Unified: Stacking the Trimmings for Sums. Mathematics Magazine; arXiv:1903.04903. arxiv.org/abs/1903.04903
  • [G] Ganzell, S. (2017). Divisibility Tests, Old and New. The College Mathematics Journal 48(1): 36–40. doi:10.4169/college.math.j.48.1.36
  • [V] Tirthaji, B. K. (1965). Vedic Mathematics. Motilal Banarsidass — the osculator (Ekādhikena Pūrvena) construction. instavm.org (PDF)
  • [Ko] Kordemsky, B. A. The Moscow Puzzles: 359 Mathematical Recreations. Ed. Martin Gardner, Dover, 1992, problem 320.
  • [W] Divisibility rule. Wikipedia. en.wikipedia.org
  • [FR] Critères de divisibilité. Wikipédia (French) — statement of Pascal's criterion and its remainder-preserving property. fr.wikipedia.org
  • [S] Sathaye, A. A universal divisibility test. University of Kentucky, MA330 notes. ms.uky.edu (PDF)
  • [D] Dickson, L. E. History of the Theory of Numbers, Volume I: Divisibility and Primality. Dover, 2005.

The full claim-by-claim discussion, with the algebra, is in the project README. If you find that any of the four items above is also already in print, please open an issue — a correct map beats a flattering one.

Try It Yourself

Watch the algorithm run, step by step

Enter any dividend and divisor. Before applying the formula, the algorithm announces the exact variation it will use — the divisor’s weight row — and then every digit, every multiplication and every subtraction is shown in full. This is the same algorithm as the Groovy implementation, producing the identical trace.

1 · The variation of the formula that will be applied
2 · The digits of the dividend (read from the ones place)
3 · Every step of the calculation
Raw execution log — identical to the Groovy implementation’s output

The log is always shown in English so that it matches the Groovy output line for line.