Recaman Sequence Calculator
Term
- The Recaman sequence grows by a simple rule: from the previous term, subtract the step number if the result is positive and has not already appeared, otherwise add the step number instead.
- Building the sequence out to step 10 passes a(9) = 21 on the way.
- At step 10 the rule subtracted: a(10) = 21 - 10 = 11.
- The next term is a(11) = 22, and the largest value in the first 11 terms is 21.
The Recaman Sequence Calculator builds Recaman's sequence term by term so you can see exactly how each number is produced. Recaman's sequence starts at 0, and at each step it subtracts the step number if the result is positive and new; otherwise it adds the step number. The sequence begins 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11. For example, a(10) = 11, reached by subtracting 10 from a(9) = 21. Not every step is a subtraction: a(15) = 24 is an addition step, because 9 - 15 is not positive. Further along, a(20) = 42, and the largest term in the first 21 terms is 62. Enter how many terms you need and the calculator applies the same rule at every step, giving you the sequence and the workings behind each term.
The method is the accepted standard for this kind of calculation because it follows the defining rule of Recaman's sequence exactly: subtract the step number when the result is positive and has not appeared before, and add it otherwise. Applying that rule in order, one step at a time, is what produces every term, so the results can be checked by hand against the published sequence. This page shows the formula, step-by-step workings, worked examples and sources, so you can trace each term from the starting 0 through values such as 11, 24 and 42 and confirm that the largest term in the first 21 terms is 62.
Worked examples
a(10)
(10)
| Recaman term a(n) | 11 |
| Previous term a(n-1) | 21 |
| Next term a(n+1) | 22 |
| Largest term so far | 21 |
a(20)
(20)
| Recaman term a(n) | 42 |
| Previous term a(n-1) | 62 |
| Next term a(n+1) | 63 |
| Largest term so far | 62 |
a(15), an addition step
(15)
| Recaman term a(n) | 24 |
| Previous term a(n-1) | 9 |
| Next term a(n+1) | 8 |
| Largest term so far | 24 |
The subtract-or-add rule
Recamán's sequence is built from a single rule applied over and over. It starts at 0, and at each step you look at the step number and decide whether to subtract it or add it. The choice is not random: the rule tells you exactly which operation to use, so anyone following it will produce the same terms. A Recamán sequence calculator simply automates this repeated decision, but the decision itself is easy to state and easy to check by hand.
Here is the rule precisely. Suppose the current term is a(n) and the next step number is n+1. First try subtracting the step number: a(n) − (n+1). If that result is positive and has not already appeared in the sequence, it becomes the next term. Otherwise, add the step number instead: a(n) + (n+1). The sequence begins at a(0) = 0, and the first step number is 1.
Working the first terms by hand shows how the rule behaves. Start at 0. Subtracting 1 gives −1, which is not positive, so add: 0 + 1 = 1. From 1, subtract 2 gives −1, again not positive, so add: 1 + 2 = 3. From 3, subtract 3 gives 0, which is positive but already in the sequence, so add: 3 + 3 = 6. From 6, subtract 4 gives 2, which is positive and new, so the next term is 2. From 2, subtract 5 gives −3, not positive, so add: 2 + 5 = 7. That hand calculation produces 0, 1, 3, 6, 2, 7, matching the published start of the sequence, which continues 13, 20, 12, 21, 11.
The rule keeps producing surprises because the two conditions — positive and new — can each force an addition. For example, a(10) = 11 is reached by subtracting 10 from a(9) = 21. Later, a(15) = 24 is an addition step, because 9 − 15 is not positive. Further along, a(20) = 42, and the largest term in the first 21 terms is 62. These checkpoints are useful when you want to confirm that a tool or a hand calculation is following the rule correctly.
The important detail is that both tests must pass before a subtraction is accepted. A result that is positive but already used, like the 0 that appeared when subtracting 3 from 3, is rejected just as firmly as a negative one. That is why the sequence does not simply zigzag downward; it alternates between small backward moves and larger forward jumps whenever the subtraction is blocked.
Walking to a(10)
The tenth term of Recaman's sequence is a(10) = 11, and you can watch it being built one step at a time. The rule is short: start at 0, and at each step subtract the step number if the result is positive and has not appeared yet; otherwise add the step number. Running those decisions in order gives the opening terms 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11. The last few entries of that list are the steps that lead directly to a(10).
Working backward from the end of that run makes the arithmetic easy to follow. The sequence reaches 13, then 20, then 12, then 21, and finally 11. Each of those moves is one application of the subtract-or-add rule, with the step number growing by one each time. The final move is the one that produces a(10): you subtract 10 from a(9) = 21, because 21 minus 10 gives 11, a positive number that has not appeared earlier in the sequence. That is why a(10) = 11.
The table below lays out those steps in order, so you can check each subtraction against the rule. Notice that every move from a(6) through a(10) is a subtraction step, and each result stays positive and new. A recaman sequence calculator applies exactly this test at every index, which is why it can extend the list far beyond the first eleven terms without losing track of which values have already been used.
Later terms show the other branch of the rule in action. At a(15) the sequence equals 24, and that is an addition step, because 9 minus 15 is not positive. The rule has no choice there: when subtraction would give a non-positive result, the step number is added instead. Further along, a(20) = 42, and the largest term among the first 21 terms is 62. Those values come from the same repeated test, applied twenty times in sequence.
| Index | Term | Step taken to reach it |
|---|---|---|
| a(6) | 13 | Subtraction step |
| a(7) | 20 | Subtraction step |
| a(8) | 12 | Subtraction step |
| a(9) | 21 | Subtraction step |
| a(10) | 11 | Subtract 10 from a(9) = 21 |
Addition steps
Most steps in Recaman's sequence are subtractions, but not all of them. The rule says that at each step you subtract the step number only if the result stays positive and has not appeared before. When either test fails, the rule flips and you add the step number instead. These addition steps are what keep the sequence alive, and they are the reason a Recaman sequence calculator is useful: tracking the two conditions by hand gets messy fast, while the calculator applies them in order and shows you exactly where each addition occurs.
The clearest small example is a(15) = 24. To get there, the rule would first try to subtract the step number 15 from the previous term, 9. That gives 9 - 15, which is negative, so the subtraction is not allowed. The positivity test fails, the rule switches to addition, and 15 is added to 9 to produce a(15) = 24. Notice that the repeat test never even comes into play here — the result was already rejected for going non-positive. The order of the two checks matters, and a good recaman sequence calculator applies them in that order so the output matches the sequence exactly.
Addition steps also appear earlier in the sequence, though they are easy to miss when you only see the list of values. The sequence begins 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11. Reading that list, you can see the terms rise and fall in uneven jumps, and each jump upward is a step where subtraction was blocked. For comparison, a(10) = 11 is a subtraction step: 10 is subtracted from a(9) = 21, and the result, 11, is both positive and new. Placing that next to a(15) = 24 shows the two branches of the rule side by side.
The additions do not stay small. a(20) = 42, and the largest term in the first 21 terms is 62. That peak comes from an addition step, since a subtraction could never push a term above its predecessor. In other words, every new record high in the sequence is created by the addition branch, which makes those steps worth watching if you are exploring how far the values can climb.
When you run the numbers through a recaman sequence calculator, watch for the steps where the value rises instead of falls. Each one marks a moment when subtracting the step number would have produced a non-positive value or a term already in the sequence, so the rule added instead. The step at a(15) = 24 is a compact illustration of the first case, and the run up to a(20) = 42 and the peak of 62 shows how much the addition branch can change the shape of the sequence.
The open question
One of the most striking things about Recamán's sequence is how much of it remains unknown. The rule is simple enough to state in a sentence: start at 0, and at each step subtract the step number if the result is positive and has not appeared before; otherwise add it. Yet a basic question about the sequence — whether every non-negative integer eventually shows up as a term — is still an open problem. No one has proved it, and no one has found a counterexample. That gap between an easy rule and an unanswered question is part of why the sequence fascinates both hobbyists and mathematicians.
The sequence begins 0, 1, 3, 6, 2, 7, 13, 20, 12, 21, 11. A few steps show the rule in action. a(10) = 11 is reached by subtracting 10 from a(9) = 21. At a(15) = 24 the step is an addition, because 9 − 15 is not positive. And by a(20) = 42, with the largest term in the first 21 terms standing at 62, the values have already wandered well above their index. A recaman sequence calculator lets you watch this wandering step by step, and it makes the central mystery easy to see: some numbers appear almost immediately, while others stay missing for a very long time.
The conjecture is that every non-negative integer eventually appears in the sequence. This has been checked over enormous computed ranges, and no missing value has turned up within those ranges. But a finite check, however large, is not a proof. Computation can show that a number appears somewhere in the sequence; it cannot establish that a number never appears, because the sequence continues forever. That asymmetry is exactly what keeps the question open.
The difficulty is not a lack of data but a lack of structure. The rule refers to two things at once — whether the subtraction result is positive, and whether it is new — and "new" depends on the entire history of the sequence. That makes the sequence hard to analyze with the usual tools. There is no known formula that predicts the n-th term directly, and no known argument that rules out a number being skipped forever.
For anyone exploring with a recaman sequence calculator, this open question is worth keeping in mind. You can generate thousands or millions of terms and confirm that familiar values eventually arrive, but the tool cannot settle the conjecture. It can only add evidence. The question of whether every non-negative integer appears remains exactly where it has always been: unproven, and waiting.
FAQs
What is Recaman's sequence?
Recaman's sequence is built step by step: at each step you subtract the step number when possible and add it otherwise. It starts 0, 1, 3, 6, 2, 7. Each term depends on the one before it, so the rule is simple to state but produces a sequence with unusual jumps and returns.
What is a(10)?
a(10) is 11. It comes from a(9) = 21 minus 10, which gives 11. Subtracting the step number was allowed here because the result stays positive and had not appeared earlier in the sequence, so the subtraction rule applied at this step.
Why does the sequence sometimes jump up?
The sequence jumps up when subtracting the step number would give a non-positive value or a value already seen. In that case the rule adds instead of subtracting, as at a(15) = 24. So upward jumps are not random; they follow directly from the subtraction rule's two conditions.
What is a(20)?
a(20) is 42. This is the twentieth term of the sequence, counting the starting 0 as the first. You can check it by applying the rule step by step from the beginning, subtracting the step number when possible and adding it otherwise.
Does every number appear in Recaman's sequence?
It is conjectured but not proven that every number appears in Recaman's sequence. The sequence is catalogued in the OEIS, the online encyclopedia of integer sequences, where its terms and properties are recorded. The question of whether all numbers eventually show up remains open.
Who created Recaman's sequence?
The sequence is named for the Colombian mathematician Bernardo Recaman Santos, who created it. It is defined by a simple rule: subtract the step number when possible, and add it otherwise. Despite that simplicity, the sequence raises open questions, including whether every number eventually appears.