OFFSET
1,2
COMMENTS
The Recamán transform of a sequence {b(n), n>0} is the sequence {r(n), n>=0} defined as follows: r(0) = 0; for n > 0, r(n) = r(n-1) - b(n) if nonnegative and not already in the sequence, otherwise r(n) = r(n-1) + b(n).
This sequence has large runs of consecutive terms.
LINKS
PROG
(PARI) { rr = 2^r=0; for (v=1, 72, forstep (s=-1, +1, 2, if (r+s*v>=0 && !bittest(rr, r+s*v), rr += 2^r+=s*v; print1 (v ", "); break))) }
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, May 30 2020
STATUS
approved