%N Variation (2) on Recamán's sequence (A005132): to get a(n), we first try to subtract n from a(n-1): a(n) = a(n-1)-n if positive and not already in the sequence; if not then a(n) = a(n-1)+n+i, where i >= 0 is the smallest number such that a(n-1)+n+i has not already appeared.
%C Variation (4) (A064389) is the nicest of these variations.
%C I would also like to get the following sequences: number of steps before n appears (or 0 if n never appears), list of numbers that never appear, height of n (cf. A064288, A064289, A064290), etc.
%D Suggested by J. C. Lagarias.
%H Nick Hobson, <a href="/A064387/a064387.py.txt">Python program for this sequence</a>
%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>
%p h := array(1..100000); maxt := 100000; a := array(1..1000); a := 1; h := 1; for nx from 2 to 1000 do t1 := a[nx-1]-nx; if t1>0 and h[t1] <> 1 then a[nx] := t1; if t1 < maxt then h[t1] := 1; fi; else for i from 0 to 1000 do t1 := a[nx-1]+nx+i; if h[t1] <> 1 then a[nx] := t1; if t1 < maxt then h[t1] := 1; fi; break; fi; od; fi; od; evalm(a);
%Y Cf. A005132, A046901, A064388, A064389. Agrees with A064389 for first 187 terms, then diverges.
%A _N. J. A. Sloane_, Sep 28 2001