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!)
A128204 a(0) = 0; a(n) = a(n-1) - (2n-1) if that number is positive and not already in the sequence, otherwise a(n) = a(n-1) + (2n-1). 2

%I #17 Feb 11 2024 12:38:44

%S 0,1,4,9,2,11,22,35,20,3,22,43,66,41,14,43,12,45,10,47,8,49,6,51,98,

%T 147,96,149,94,37,96,157,220,155,88,19,90,17,92,15,94,13,96,181,268,

%U 179,270,177,82,179,80,181,78,183,76,185,74,187,72,189,70,191,68,193,320

%N a(0) = 0; a(n) = a(n-1) - (2n-1) if that number is positive and not already in the sequence, otherwise a(n) = a(n-1) + (2n-1).

%C 'Recamán transform' (see A005132) of the odd numbers.

%H Nick Hobson, <a href="/A128204/a128204.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>

%e Consider n=7. We have a(6)=22 and try to subtract 13, the 7th odd number. The result, 9, is certainly positive, but we cannot use it because 9 is already in the sequence. So we must add 13 instead, getting a(7) = 22 + 13 = 35.

%o (PARI) A128204(N,s/*=1 to print all terms*/)={my(a=0,u=0); for( n=1,N, s&print1(a","); u=bitor(u,2^a+=if(a<2*n || bittest(u,a+1-2*n), 2*n-1,1-2*n)));a} \\ _M. F. Hasler_, Mar 07 2012

%Y Cf. A005132, A053461, A064365, A123483.

%K easy,nonn

%O 0,3

%A _Nick Hobson_, Feb 19 2007

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 23 16:40 EDT 2024. Contains 371916 sequences. (Running on oeis4.)