This site is supported by donations to The OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A063733 A variant of Recamán's sequence: a(0)=1, a(n) = a(n-1)-(n-1) if positive and new, else a(n) = a(n-1)+(n-1). 10

%I

%S 1,1,2,4,7,3,8,14,21,13,22,12,23,11,24,10,25,9,26,44,63,43,64,42,19,

%T 43,18,44,17,45,16,46,15,47,80,114,79,115,78,40,79,39,80,38,81,37,82,

%U 36,83,35,84,34,85,33,86,32,87,31,88,30,89,29,90,28,91,27

%N A variant of Recamán's sequence: a(0)=1, a(n) = a(n-1)-(n-1) if positive and new, else a(n) = a(n-1)+(n-1).

%H R. Zumkeller, <a href="/A063733/b063733.txt">Table of n, a(n) for n = 0..10000</a>

%H <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a>

%F a(n+1) = A005132(n) - 1; A005132 is Recamán's sequence. - _Franklin T. Adams-Watters_, Mar 12 2010

%t a[0] = 1; a[n_] := a[n] = If[an = a[n-1] - (n-1); an > 0 && FreeQ[Array[a, n-1], an], an, a[n-1] + (n-1)]; Table[a[n], {n, 0, 65}] (* _Jean-François Alcover_, Feb 18 2018 *)

%o a063733 n = a063733_list !! n

%o a063733_list = 1 : f 0 [1] where

%o f x ys@(y:_) | u > 0 && u `notElem` ys = u : f (x + 1) (u : ys)

%o | otherwise = v : f (x + 1) (v : ys)

%o where u = y - x; v = x + y

%o -- _Reinhard Zumkeller_, Jul 02 2015

%o (Python)

%o l=[1]

%o for n in xrange(1, 101):

%o x=l[n - 1] - (n - 1)

%o if x>0 and not x in l: l+=[x, ]

%o else: l+=[l[n - 1] + (n - 1)]

%o print l # _Indranil Ghosh_, Jun 02 2017

%Y See A005132, which is the main entry for this sequence. A063753 = 1 + A005132. A row of A066201. Also a row of A066202.

%Y Cf. A141126.

%K nonn,nice,easy,look

%O 0,3

%A _N. J. A. Sloane_, Sep 05 2001

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent | More pages
The OEIS Community | Maintained by The OEIS Foundation Inc.

Last modified November 16 00:11 EST 2018. Contains 317252 sequences. (Running on oeis4.)