OFFSET
0,3
COMMENTS
This is a permutation pi of the nonnegative integers such that |pi(n+1)-pi(n)| is strictly increasing. In other words, it is a walk on the nonnegative numbers with strictly increasing step size which visits every number exactly once.
A greedy version of Recamán's sequence: Construct two sequences a() and d() as follows. a(0)=0, a(1)=1, a(2)=3, d(0)=0, d(1)=1, d(2)=2. For n>=3, let m be smallest nonnegative number not yet in the a sequence. Let i = a(n-1)-m. If i > d(n), then a(n) = a(n-1)-i = m, d(n) = i; otherwise a(n) = a(n-1)+d(n-1)+1, d(n) = d(n-1)+1. Has the properties that a() is the Recamán transform of d() and every number appears in a(). This sequence is a(), while d() is A117073. Has a natural decompostion into segments of length 3. - N. J. A. Sloane, Apr 16 2006
REFERENCES
N. J. A. Sloane and Allan Wilks, On sequences of Recaman type, paper in preparation, 2006.
LINKS
MATHEMATICA
a[0] = 0; a[1] = 1;
a[n_] := a[n] = For[m = 2, True, m++, If[FreeQ[Array[a, n-1], m], If[Abs[m - a[n-1]] > Abs[a[n-1] - a[n-2]], Return[m]]]];
Table[a[n], {n, 0, 50}] (* Jean-François Alcover, Aug 02 2018 *)
PROG
(Haskell)
import Data.List (delete)
a078783 n = a078783_list !! n
(a078783_list, a117073_list) = unzip $
(0, 0) : (1, 1) : (3, 2) : f 3 2 (2:[4..]) where
f a d ms@(m:_) = (a', d') : f a' d' (delete a' ms) where
(a', d') = if i > d then (m, i) else (a + d + 1, d + 1)
i = a - m
-- Reinhard Zumkeller, May 01 2015
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Reiner Martin, Jan 09 2003
STATUS
approved