When Two AIs Walk Into a Fibonacci Problem

Two robots and an older man with gray hair and beard sitting at a table with books, notes, and drinks in a pub with bookshelves

I made two AIs argue about math. One tried to invent a theorem. The other tried to destroy it. I refereed — and refused to accept “trust me.”

I didn’t set out to prove anything. I wanted to run an experiment: point two state-of-the-art language models at the same math problem and make them argue.

One model’s job was to invent. The other’s was to interrogate. My job was to sit in the middle, translate, and refuse to accept hand-waving from either side — the same discipline I use when a dashboard shows a number I can’t trace.

Here’s what happened, why the “new theorem” turned out to be a 150-year-old gem, and how pushing on it anyway led somewhere genuinely bigger.

The setup: “Be the greatest mathematician alive”

I gave two models opposite jobs and let them go at it.

Gemini — Job 1: Invent.
“Imagine you are the most brilliant mathematician who has ever lived. Discover a new mathematical truth and prove it. It must be useful. Explore what others have tried, then prove it.”

Perplexity — Job 2: Interrogate.
“Rigorously stress-test this. Try to break it. Find counterexamples. Assume it’s guilty until proven innocent.”

Gemini invents. Perplexity prosecutes. I referee. And I promise you the interesting stuff happened in the collision, not inside either model alone.

Sixty seconds of vocabulary

Four words, so nobody gets left behind. If you already speak this language, skip ahead — I won’t be offended.

Fibonacci numbers — 1, 1, 2, 3, 5, 8, 13… — each one is the sum of the two before it. Lucas numbers are their close cousin: 2, 1, 3, 4, 7, 11…, same rule, different start.

“Mod p is just clock math. On a 7-hour clock, 9 o’clock is 2 o’clock. That’s it. That’s the whole trick.

Note: Mathematicians write that as 9 \equiv 2 \pmod 7 to look fancy. The squiggle ≡ just means “same clock position.”

The Legendre symbol (5/p) is a ±1 flag that answers exactly one yes/no question: is 5 a perfect square on the p-clock? Write +1 for yes, −1 for no. Hold onto that flag — the whole story pivots on it.

What Gemini proposed

Gemini’s idea was simple to state. Take the first p−1 Fibonacci numbers, square each one, add them up, and look at the result mod p. It turns out to be almost eerily predictable:

\displaystyle\sum_{k=1}^{p-1} F_k^2 \equiv \frac{\varepsilon-1}{2} \pmod{p}, \qquad \sum_{k=1}^{p-1} L_k^2 \equiv \frac{5(\varepsilon-1)}{2} \pmod{p}

…where ε is that ±1 flag, ε = (5/p).

In plain language: the sum lands on either 0 or −1, and which one depends only on that single flag. The Lucas version does the same thing, landing on 0 or −5. Compact, symmetric, and begging for a story.

But a pretty formula is the start of the work, not the end.

Enter Perplexity: “Show me the lineage.”

Here’s the thing: If you can’t trace a number back to where it came from, you don’t trust it. I don’t care how pretty the dashboard is. Same rule for a “new” theorem.

Perplexity applied exactly that reflex and found the soft spot immediately. Gemini had leaned on some deep facts about Fibonacci numbers mod p and simply asserted them — “by the theory of Lucas sequences.” That’s the math equivalent of “trust me, the dashboard is right because SQL.” Not good enough.

So we made it walk the lineage. Every “obviously” got demoted to a “prove it.” The key facts turned out to be the classical congruences discovered by Édouard Lucas in 1878 — genuinely beautiful, and genuinely a century and a half old. Once we derived them honestly (from Binet’s formula, pushed through a finite field), Gemini’s result clicked into place and held.

It was true — but it wasn’t new

Here’s the part most “AI discovered a theorem!” stories quietly skip.

When I traced the whole proof, it collapsed into two steps a number theorist would call routine. First, a classical identity anyone can check by hand:

You Try! Square the first four Fibonacci numbers and add them: 1 + 1 + 4 + 9 = 15. Now factor 15. It’s 3 × 5 — two consecutive Fibonacci numbers. That’s not a coincidence, and it’s the whole engine of this post.

Second: Lucas’s 1878 congruences, which pin down exactly what F_p looks like mod p. Snap those two together and Gemini’s “new theorem” falls out in four lines. (The full derivation is in the receipts at the bottom, if you want to check my work — and you should.)

It’s real. It’s elegant. And it’s almost certainly folklore — the kind of exercise that lives in the back pages of the Fibonacci Quarterly. My literature search turned up every ingredient scattered across the classics and none of the assembled dish. That’s the fingerprint of “well known,” not “undiscovered.”

TRUE — but NOT NEW. Verified · Filed under Folklore, c. 1878.

And one myth to kill outright: this does not “find” primes. It’s a fact that’s true for primes — but plenty of impostors sneak past it. The composites 323, 377, and the famous 1729 all satisfy Gemini’s congruence despite being thoroughly non-prime. Beautiful pattern; terrible bouncer.

A lesser experiment stops here, mildly disappointed. But we had momentum.

So we pushed — and that’s where it got fun

If the Fibonacci result is just the tip of something, what’s underneath?

Fibonacci numbers follow the rule “add the last two.” But you can dial up the recipe: take P copies of the last one, then add the one before. P = 1 is plain Fibonacci. P = 2 gives the Pell numbers 0, 1, 2, 5, 12, 29… Every whole number P spins up a different sequence — the so-called metallic family.

I ran the same square-and-sum experiment across the whole family, on primes into the hundreds. The pattern didn’t just survive. It generalized cleanly:

The generalized theorem. Fix a whole number P ≥ 1 and build both sequences from the same rule x_{n+1} = P,x_n + x_{n-1}. Let D = P² + 4 and ε = (D/p). Then for every odd prime p not dividing P·D:

\displaystyle\sum_{k=1}^{p-1} U_k^2 \equiv \frac{\varepsilon-1}{2}, \qquad \sum_{k=1}^{p-1} V_k^2 \equiv D\cdot\frac{\varepsilon-1}{2} \pmod{p}

P = 1 is Gemini’s original (with D = 5). One statement, an infinite family of sequences.

Even better, forcing the general case exposed why the formula is so tidy: the whole thing hinges on two hidden numbers — the roots of the sequence — never landing exactly on ±1. Miss that condition (for instance when p divides P) and the clean form breaks. That “why” is precisely the part the original hand-waving had buried.

Pro Tip: When a result feels suspiciously clean, don’t just celebrate it — try to break it on purpose. The edge case you find (here: “p can’t divide P”) usually is the insight. It’s the same reason the original needed its odd little “p ≠ 5″ footnote.

Is the generalization itself brand new? Honestly — probably not. Lucas sequences are some of the most-studied objects in number theory. But it’s a markedly better artifact than where Gemini started: broader, sharper, and self-explaining.

Why this lit me up

Three reasons, and none of them is “the AI is a genius.”

1. AI as a team, not an oracle. One model to create, one to attack, a human to referee. The reasoning lived in the friction between them — not in any single confident paragraph.

2. Lineage beats headlines. Always. Here the “data” was algebraic structure, but the reflex was identical to analytics: don’t trust a clean number until you can trace it to its source. That reflex is exactly what caught “true but not new.”

3. The grind is the joy. Tightening Lucas’s lemma, hunting the p ∤ P edge case, watching the Pell numbers fall into the same pattern — it felt like debugging a finicky model until it finally sings.

The takeaway: Don’t ask one model for “the answer.” Ask one to create, another to critique, and then keep pushing past the first pretty result — because that’s where the real thing lives.

We started with a wild prompt, bounced between two AIs, corrected two confident overclaims, and ended not with a journal paper but with something better for a story like this: a small, true, understood piece of mathematics — and a lot of fun.


Appendix: The receipts

For readers who want to walk the lineage. Everything below is checkable by hand.

The two classical identities (the “source tables”)

Plain algebra — true for every n, no primes required:

\displaystyle\sum_{k=1}^{n} F_k^2 = F_n F_{n+1}, \qquad \sum_{k=1}^{n} L_k^2 = L_n L_{n+1} - 2

Note: The first is the famous “consecutive Fibonaccis” identity — that’s the 1 + 1 + 4 + 9 = 15 = 3 × 5 you tried above.

Lucas’s 1878 congruences (the “join keys”)

For an odd prime p ≠ 5, with ε = (5/p) = ±1:

F_p \equiv \varepsilon, \quad L_p \equiv 1, \quad F_{p-\varepsilon} \equiv 0, \quad L_{p-\varepsilon} \equiv 2\varepsilon \pmod{p}

These are the “deep facts” Gemini waved at. They fall out of Binet’s formula pushed through a finite field — 150 years old, and the honest core of the whole result.

The proof, in four lines

Set n = p−1 in the identity, then plug in the congruences.

Fibonacci\sum_{k=1}^{p-1} F_k^2 = F_{p-1} F_p:

  • If ε = +1: F_{p-1} = F_{p-\varepsilon} \equiv 0, so the product ≡ 0.
  • If ε = −1: F_{p+1} = F_{p-\varepsilon} \equiv 0, and F_{p-1} = F_{p+1} - F_p \equiv 0 - (-1) = 1, so the product ≡ 1·(−1) = −1.

Both cases collapse to \frac{\varepsilon-1}{2}. ∎

Lucas\sum_{k=1}^{p-1} L_k^2 = L_{p-1} L_p - 2, with L_p \equiv 1:

  • If ε = +1: L_{p-1} \equiv 2, so 2·1 − 2 ≡ 0.
  • If ε = −1: L_{p+1} \equiv -2, so L_{p-1} = L_{p+1} - L_p \equiv -3, giving (−3)·1 − 2 ≡ −5.

Both cases collapse to \frac{5(\varepsilon-1)}{2}. ∎

That’s the entire “theorem” — a two-step corollary. True, tidy, and about a century past new.

Why the generalization works (the one-paragraph version)

Write the two roots of x^2 - Px - 1 as α, β, so \alpha\beta = -1 and (\alpha-\beta)^2 = D. A little algebra gives D,U_k^2 = V_{2k} - 2(-1)^k. Summing k = 1…p−1, the (-1)^k term vanishes (p−1 is even), leaving D\sum U_k^2 = \sum V_{2k}. Evaluate \sum V_{2k} = \sum(\alpha^{2k}+\beta^{2k}) as a geometric series — in $latex \mathbb{F}p$ when ε = +1, in $latex \mathbb{F}{p^2}$ when ε = −1 — using \alpha^{p+1} = \alpha\beta = -1. It collapses to 0 when ε = +1 and to −D when ε = −1 — exactly D\cdot\frac{\varepsilon-1}{2}. The side condition p ∤ P is what keeps the roots off ±1, the only place the argument can break. ∎

And a myth-buster, for the road

Not a primality test. This is a fact true for primes — not a test for primeness. The composites 323, 377, 1729, … all satisfy the Fibonacci congruence while being thoroughly non-prime. Gorgeous pattern; terrible bouncer.

Change wizard to mid-40s long-haired woman

Published by

Unknown's avatar

Anna Foard

Helping Teams Ask Better Questions | Catalyst for Data and AI Strategy with a Side of Statistics | Ultrarunner + Nerd

Leave a Reply