%I A064389
%S A064389 1,3,6,2,7,13,20,12,21,11,22,10,23,9,24,8,25,43,62,42,63,41,18,
%T A064389 44,19,45,72,100,71,101,70,38,5,39,4,40,77,115,76,36,78,120,163,
%U A064389 119,74,28,75,27,79,29,80,132,185,131,186,130,73,15,81,141,202
%N A064389 Variation (4) on Recaman'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 we try to add n: a(n) = a(n-1)+n
if not already in the sequence; if this fails we try to subtract
n+1 from a(n-1), or to add n+1 to a(n-1), or to subtract n+2, or
to add n+2, etc., until one of these produces a positive number not
already in the sequence - this is a(n).
%C A064389 This is the nicest of these variations. Is this a permutation of the
natural numbers?
%C A064389 The number of steps before n appears is the inverse series, A078758.
The height of n is in A126712.
%D A064389 Suggested by J. C. Lagarias.
%H A064389 Nick Hobson, <a href="b064389.txt">Table of n, a(n) for n=1..10000</a>
%H A064389 Nick Hobson, <a href="a064389.py.txt">Python program for this sequence</
a>
%H A064389 <a href="Sindx_Rea.html#Recaman">Index entries for sequences related
to Recaman's sequence</a>
%H A064389 <a href="Sindx_Per.html#IntegerPermutation">Index entries for sequences
that are permutations of the natural numbers</a>
%p A064389 h := array(1..100000); maxt := 100000; a := array(1..1000); a[1] := 1;
h[1] := 1; for nx from 2 to 1000 do for i from 0 to 100 do t1 :=
a[nx-1]-nx-i; if t1>0 and h[t1] <> 1 then a[nx] := t1; if t1 < maxt
then h[t1] := 1; fi; break; fi; 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;
od; evalm(a);
%Y A064389 Cf. A005132, A046901, A064387, A064388. Agrees with A064387 for first
187 terms, then diverges.
%Y A064389 Sequence in context: A005132 A064388 A064387 this_sequence A118201 A113880
A098141
%Y A064389 Adjacent sequences: A064386 A064387 A064388 this_sequence A064390 A064391
A064392
%K A064389 nonn,easy,nice
%O A064389 1,2
%A A064389 N. J. A. Sloane (njas(AT)research.att.com), Sep 28 2001
|