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.

Articles by others on the same topic (1)

Recamán's sequence is a well-known mathematical sequence defined recursively. It is named after the mathematician Bernardo Recamán. The sequence is defined as follows: 1. The first term \( a(0) \) is 0: \( a(0) = 0 \) 2.