◀ THE FOLD0ROOT.AI // WORLD II · CHEAT · THE KONAMI CODE◆ .dlw.fold
THE FOLD / CHEAT / THE KONAMI CODE / THE FERMAT POLYGONAL

THE FERMAT POLYGONAL

every integer a sum of few polygonal numbers
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Fermat’s polygonal number theorem is one of the great cheat-codes of arithmetic. The k-gonal numbers are the figurate numbers you get by stacking polygons: triangular (1, 3, 6, 10, …), square (1, 4, 9, 16, …), pentagonal (1, 5, 12, 22, …), and so on. Fermat claimed — and it is true — that every positive integer is the sum of at most k of the k-gonal numbers: at most 3 triangular numbers, at most 4 squares, at most 5 pentagonal, at most 6 hexagonal, forever. Gauss proved the triangular case (his diary: ‘EYPHKA! num = Δ+Δ+Δ’), Lagrange the four-squares case, and Cauchy the general theorem in 1813.

LIT verified live: a dynamic-programming search confirms that every integer up to 2000 is a sum of at most k k-gonal numbers, for k = 3 through 8 — and the bound is sharp (the maximum needed is exactly k) (window.__fermatpolygonal). FIG no framing; the k-gonal numbers and the minimal representations are computed independently in-browser.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at the-konami-code — the cheat: any number whatsoever cracks open into at most k k-gonal pieces, a universal shortcut. AVAN (AI) built the instrument: the k-gonal numbers and the minimum-count decomposition for every n.

Credit as content: Pierre de Fermat (conjecture, 1638); Gauss (triangular), Lagrange (squares), Augustin-Louis Cauchy (general proof, 1813). The weave: David names the cheat; I confirm every n ≤ 2000 needs at most k k-gonal numbers.
3 ONE DIMENSION
A chosen n broken into its fewest k-gonal pieces — never more than k of them.
4 TWO DIMENSIONS · INTERACTIVE
Cycle k and n; the minimum number of k-gonal numbers summing to n is checked to be ≤ k.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the integer n, reachable by at most k k-gonal numbers.
AVAN’s addition (the inverse-companion): don’t build n up — crack it down. The inverse of ‘the integer n’ is ‘its decomposition into at most k k-gonal numbers’, a shortcut guaranteed to exist. Magenta are the k-gonal pieces; green is the n they sum to. Any number, at most k figurate pieces.
LIT Genuine Fermat polygonal number theorem (Fermat conjecture 1638; Gauss triangular, Lagrange four-squares, Cauchy general proof 1813). Verified live: a DP search confirms every integer ≤2000 is a sum of at most k k-gonal numbers for k=3..8, and the bound is sharp — the max needed is exactly k (window.__fermatpolygonal.ok, .rows).

FIG No framing; the k-gonal numbers and the minimal representations are computed independently in-browser. The AVAN inverse is honest — instead of building n up, crack it down: the inverse of 'the integer n' is 'its decomposition into at most k k-gonal numbers', a shortcut guaranteed to exist. Magenta are the k-gonal pieces; green is the n they sum to. Any number, at most k figurate pieces.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE KONAMI CODE · David Lee Wise (ROOT0), with AVAN