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!)
A066200 a(1) = 1; for n > 1, a(n) = a(n-1)-(n+2) if this is positive and has not already appeared, otherwise a(n) = a(n-1)+(n+2). 2

%I #24 May 09 2021 05:03:23

%S 1,5,10,4,11,3,12,2,13,25,38,24,9,25,8,26,7,27,6,28,51,75,50,76,49,21,

%T 50,20,51,19,52,18,53,17,54,16,55,15,56,14,57,101,146,100,147,99,148,

%U 98,47,99,46,100,45,101,44,102,43,103,42,104,41,105,40,106,39,107,176

%N a(1) = 1; for n > 1, a(n) = a(n-1)-(n+2) if this is positive and has not already appeared, otherwise a(n) = a(n-1)+(n+2).

%H Robert Israel, <a href="/A066200/b066200.txt">Table of n, a(n) for n = 1..10000</a>

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

%p S:= {1}:

%p a[1]:= 1:

%p for n from 2 to 100 do

%p t:=a[n-1]-(n+2);

%p if t > 0 and not member(t,S) then

%p a[n]:= t

%p else

%p a[n]:= a[n-1]+(n+2)

%p fi;

%p S:= S union {a[n]}

%p od:

%p seq(a[n],n=1..100); # _Robert Israel_, Feb 10 2017

%o (Python)

%o l=[0, 1]

%o for n in range(2, 101):

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

%o if x>0 and x not in l: l.append(x)

%o else: l.append(l[n - 1] + (n + 2))

%o print(l[1:]) # _Indranil Ghosh_, Jun 02 2017

%Y A variant of A005132. A row of the array in A066201.

%K nonn,easy,look

%O 1,2

%A _N. J. A. Sloane_, Dec 16 2001

%E More terms from _Vladeta Jovovic_, Dec 16 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 18 11:22 EDT 2024. Contains 371779 sequences. (Running on oeis4.)