The name "Recamán's sequence" refers to at least two integer sequences attributed to B. Recamán (Sloane 1999). One is the sequence formed by taking
and, for
, letting
|
(1)
|
which can be succinctly defined as "subtract if you can, otherwise add." The first few terms are 1, 3, 6, 2, 7, 13, 20, 12, 21, 11, ... (OEIS A005132), illustrated above.
A view of the first 256 terms as binary bits is shown above.
For a positive integer , let
be the first position at which
occurs, or
if it never occurs. The sequence
,
, ... begins 1, 4, 2, 131, 129, 3, 5, ... (OEIS A057167).
Its high-water marks are 1, 4, 131, 99734, 181653,
328002, ... (OEIS A064227), attained for
, 2, 4, 19, 61, 879, ... (OEIS A064228).
These four cited OEIS sequences include an initial 0,
omitted here.
Another sequence defined by Recamán starts with
and, for
,
satisfies (Guy and Nowakowski 1995, Sloane 1999)
|
(2)
|
The first few terms of this sequence are 1, 1, 2, 6, 24, 120, 20, 140, 1120, ... (OEIS A008336).