login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
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). 11

%I #29 Mar 09 2021 19:12:44

%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 Reinhard 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 (Haskell)

%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 range(1, 101):

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

%o if x > 0 and x not in l:

%o l.append(x)

%o else:

%o l.append(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 See also A078943.

%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 | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 29 13:17 EDT 2024. Contains 372114 sequences. (Running on oeis4.)