Recamán's sequence

Recamán's sequence starts at 0 and always tries to step backward. It steps forward only when the backward spot would be negative or is already in the sequence. The same numbers, drawn as alternating semicircles, make the spiral.

Recamán semicircles alternating above and below a number line
Recamán semicircles alternating above and below a number line

A hop that prefers the past

Bernardo Recamán Santos defined the sequence, and Neil Sloane catalogued it as OEIS A005132. It starts at a₀ = 0. For each later step n, look at aₙ₋₁ − n. If that integer is positive and has not appeared yet, it is aₙ. Otherwise aₙ = aₙ₋₁ + n. Zero is already the starting term, so a backward hop never lands on it. OEIS now phrases the test as nonnegative and unused. That is the same rule: 0 is used, so the backward value still has to be a positive integer that is new.

The first fifteen terms

The sequence begins 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24. Step 1 cannot subtract: 0 − 1 = −1, so it adds and lands on 1. Step 2 does the same and lands on 3. Step 3 would return to 0, which is already used, so it lands on 6. Step 4 is the first backward hop: 6 − 4 = 2, and 2 is free. The forward jumps then continue through 7, 13, and 20 before the sequence finds 12.

The step that looks like it should be 6

At step 7 the previous term is 13. Subtracting gives 13 − 7 = 6. Six is positive, but it is already a₃, so the rule refuses it and adds instead: 13 + 7 = 20. The same thing happens whenever the backward spot is taken. Step 6 refuses 1, step 9 refuses 3, and step 11 refuses 0. After these fifteen steps the positive integers that have appeared are 1, 2, 3, 6, 7, 9, 10, 11, 12, 13, and 20 through 24. The smallest missing number in that prefix is 4. Four itself does not appear until step 131.

Semicircles on the number line

Join aₙ₋₁ to aₙ with a semicircle whose diameter is the hop length n. Odd steps arch above the line and even steps arch below it. Backward hops, drawn in teal, tuck into gaps. Forward hops, drawn in amber, reach a new high. The pile of arcs is the picture popularized by Edmund Harriss and by Numberphile: a cross-section that looks like a shell, built from one greedy rule.

Hearing the hops

The same values can be played as notes. In the app, Sound maps each new term onto a natural minor scale: a backward hop is a sine tone, and a forward hop is a softer triangle. The melody is unpredictable because the sequence keeps falling into unused integers and then leaping ahead again. Turn Sound on and press play by choosing the Melody favorite, or tick Sound while the arcs are growing.

An open question, and 852,655

Neil Sloane conjectured that every nonnegative integer eventually appears. That is still unproved. The early gaps do fill: 4 is missing from the first fifteen terms and then shows up at step 131. The small number that has held out is 852,655. Allan Wilks already found it missing after 10^15 terms. Benjamin Chaffin kept extending the computation, and in February 2026 reported that after 10^612 terms, 852,655 is still the smallest missing number.

Explore it in PictorX

Open Recamán's sequence to grow the semicircles, read the step table for the first fifteen terms, or switch to Missing numbers and watch the smallest gap in the prefix. Drag to move the arcs, scroll to zoom, and double-click to fit them again. Save a PNG or open the canvas in the PictorX editor. The Fibonacci sequence and the Collatz Conjecture are two other pictures drawn from a short rule.

Frequently asked questions

What is Recamán's sequence?

The sequence with a₀ = 0 and, for n > 0, aₙ = aₙ₋₁ − n when that value is positive and new, otherwise aₙ = aₙ₋₁ + n. It is OEIS A005132. The first terms are 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, 22, 10, 23, 9, 24.

Why does step 7 land on 20 rather than 6?

13 − 7 = 6, and 6 is already in the sequence, so the backward hop is refused. The step adds 7 instead and lands on 20.

What do the semicircles mean?

Each semicircle connects aₙ₋₁ to aₙ and has diameter n. Odd steps go above the number line and even steps go below. Teal arcs hopped backward into a free integer. Amber arcs jumped forward.

Does every positive integer appear?

Nobody knows. Sloane conjectured that every nonnegative integer appears eventually. After 10^612 terms, computed by Benjamin Chaffin and reported in February 2026, 852,655 is still the smallest missing number.

Does the drawing leave my device?

No. The sequence, the arcs, the gap scan, and the melody are computed in your browser. Save a PNG or open the canvas in the PictorX editor.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Try Recamán's sequence