OEIS entry A005132 2026-10-24
oeis.org/A005132
Primary database record for Recamán's sequence. Relevant locators are its definition, offset-zero initial terms, the comment recording the first repeated value at indices 20 and 24, and the reference to the 29 January 1991 letter by Bernardo Recamán Santos. Later additions to this evolving record are not needed for the 2019 solution.
Recamán's sequence 2026-10-25
The integer sequence proposed by Bernardo Recamán Santos starts at zero. At step , subtract if the result is positive and has not appeared before; otherwise add . The commonly written nonnegative version gives the same sequence because zero is already present. The initial values are . The addition branch can repeat a value: . Avoiding a repeated subtraction is therefore not a global injectivity condition.[ref]
Since , induction gives . A prefix scan needs only constant extra storage but can take quadratic membership work. A bitset-style bounded membership table makes each lookup constant time, while its allocation cost depends on the chosen value universe. This separates the number of generated terms from the range of possible stored values.