Skip to content
Subscribe
All writing
MathLeanAI agentsFormal proof

Count From 0 or From 1? One Rule, Written Two Ways (OEIS A025273)

The guess for this sequence was written counting from 0, on a page that counts from 1. Both are fine. Before anything could be proved, someone had to pick one and restate the rule so a computer would read it the way a person does.

Does a list start at position 0 or position 1? Programmers have been tripping over that for as long as there have been programmers. Mathematics has the same trap, and this problem sits right on top of it.

The sequence

Start with 1, 0, 1, 1. To get each new number, line the list up against itself in reverse, multiply the pairs, and add.

5th = 1×1 + 0×1 + 1×0 + 1×1 = 2
6th = 1×2 + 0×1 + 1×1 + 1×0 + 2×1 = 5
1, 0, 1, 1, 2, 5, 12, 29, 72, 182, 466, 1207, 3158, 8334

This is A025273 in the OEIS, where the first entry is officially number 1.

The first numbers of OEIS sequence A025273

The guess, and its fine print

The shortcut rule recorded on the page begins with a short remark in brackets: with offset 0 instead of 1.

That means the person who wrote the rule was counting the entries from 0, and said so. Nothing is wrong with that. Their rule starts with (n+1)·a(n). Under the page's own numbering, where counting starts from 1, the same rule starts with n·a(n), and every other part of it shifts to match.

Both versions describe the same fact about the same numbers. But they are different formulas. Feed either one the wrong numbering and it is simply false.

A human reader fixes this without thinking. A proof checker cannot. Lean will prove exactly the formula you give it about exactly the list you define, or it will refuse.

So before anyone could prove anything, the person who wrote the formal statement for the site had to pick a numbering and rewrite the rule to fit. They went with the page's numbering, starting from 1:

n·a(n) − (4n−6)·a(n−1) + (4n−12)·a(n−2) − (4n−18)·a(n−3) + (4n−24)·a(n−4) = 0

With n = 7, counting from 1:

7×12 - 22×5 + 16×2 - 10×1 + 4×1 = 0
84 - 110 + 32 - 10 + 4 = 0

That translation is not my work or my agent's. It is credited on the problem page. I point it out because it is the step where this kind of project most easily goes wrong. If the statement is off by one, a perfect proof proves the wrong thing.

How the proof goes

Packed into one object A, the whole list satisfies

A^2 = A - (x - x^2 + x^3 - x^4)

The proof takes the rate of change of that, combines the two so A^2 cancels, and reads off the result slot by slot. That route is laid out in the first problem of the night.

The numbering question comes back at the last step. "Slot by slot" means deciding which slot of the equation corresponds to which n in the rule. Get it wrong by one and Lean rejects the proof with an unhelpful message about two expressions not being equal. The agent's method note tells the helpers to test the slot alignment with plain arithmetic first, before writing any Lean, for exactly this reason.

What I took from it

Off-by-one errors are not a sign of carelessness. They come from two reasonable conventions meeting. One system counts from 0, the other from 1, each is consistent on its own, and the bug lives at the join.

I have chased this in date ranges, in page numbers, in inventory counts where one system includes the item in hand and the other does not. The fix is always the same boring step: write down which convention you are using, at the boundary, where both sides can see it.

The numbers

The first accepted proof was 6,344 characters, the longest starting point in its family of fifteen. Ours is 751, about 8.4 times shorter, accepted as pull request 62235. It is the shortest proof of this problem as of November 29, 2026.

Proof length: 6,344 characters for the first accepted proof, 751 for mine

Someone else proved it first. Mine is a shorter proof of the same statement.

Get the next build note.

What I'm building, what worked, and what broke, whenever there's something worth sharing.

Subscribe to my newsletter

Keep up with the work.

My notes on useful AI, the systems I build, and what I learn running a business.