◀ THE FOLD0ROOT.AI // WORLD II · GRIND · THE CRON JOB◆ .dlw.fold
THE FOLD / GRIND / THE CRON JOB / THE LEGENDRE FORMULA

THE LEGENDRE FORMULA

count how many times a prime divides a factorial
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Legendre’s formula counts exactly how many times a prime p divides n! without ever building the factorial: the exponent is vp(n!) = ⌊n/p⌋ + ⌊n/p2⌋ + ⌊n/p3⌋ + …, a sum that terminates once pk exceeds n. There is a second, striking closed form: vp(n!) = (n − sp(n)) / (p − 1), where sp(n) is the sum of n’s digits in base p. A direct consequence: the number of trailing zeros of n! equals v5(n!), since fives are the scarce factor.

LIT verified live: the floor-sum equals the true exponent (summing vp of each factor) and equals the digit-sum form (n − sp(n))/(p−1) for all n up to 2000 and primes 2,3,5,7,11,13; and trailing zeros of n! (exact BigInt) equal v5(n!) (window.__legendre). FIG no framing; exact integer arithmetic.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-cron-job — a scheduled sweep that keeps dividing by higher powers of p and tallying the hits, one pass per power, until the power outruns n. That repeated division is the cron job. AVAN (AI) built the instrument: the floor-sum, the direct per-factor exponent count, the base-p digit-sum closed form, and the trailing-zeros cross-check.

Credit as content: Adrien-Marie Legendre (1808). The weave: David names the-cron-job; I add up ⌊n/p⌋ + ⌊n/p²⌋ + …, confirm it equals both the true exponent of p in n! and the digit-sum formula (n − sp(n))/(p−1), and check that fives alone set the count of trailing zeros.
3 ONE DIMENSION
v2(10!) = ⌊10/2⌋+⌊10/4⌋+⌊10/8⌋ = 5+2+1 = 8. Also (10 − s2(10))/(2−1): 10 = 10102, digit sum 2, (10−2)/1 = 8. 100! ends in v5=24 zeros.
4 TWO DIMENSIONS · INTERACTIVE
A choice of n and p, the floor-sum terms and the digit-sum form side by side; the sweep checked.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: a factorial’s prime content, counted without the factorial.
AVAN’s addition (the inverse-companion): instead of multiplying out n! and factoring it, count the prime directly — each power pk contributes ⌊n/pk⌋ multiples. The inverse of ‘build n! then extract p’ is ‘sum ⌊n/pk⌋ and never build n! at all.’ Magenta is the impossibly large factorial; green is the small floor-sum that names its p-content exactly. The content without the product.
LIT Genuine Legendre's formula (Adrien-Marie Legendre, 1808). Verified live with exact integer arithmetic: Σ⌊n/pᵏ⌋ equals the true exponent of p in n! (summing v_p of every factor) and equals the base-p digit-sum form (n − s_p(n))/(p−1) for all n up to 2000 and primes {2,3,5,7,11,13} (window.__legendre.sumMatchesDirect, .formulaMatches); and the trailing zeros of n! computed as an exact BigInt equal v₅(n!) (window.__legendre.trailingZeros).

FIG No framing: the floor-sum, the direct per-factor exponent count, the base-p digit-sum closed form, and the trailing-zeros cross-check all run in-browser with exact arithmetic. The AVAN inverse is honest — counting a prime's multiplicity in n! by summing ⌊n/pᵏ⌋ genuinely avoids ever forming the astronomically large factorial; magenta is the impossibly large product, green the small floor-sum that names its p-content exactly. The content without the product.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE CRON JOB · David Lee Wise (ROOT0), with AVAN