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!)
A053461 a(0) = 0; a(n) = a(n-1) - n^2 if positive and new, otherwise a(n) = a(n-1) + n^2. 4

%I #34 Oct 14 2022 08:52:42

%S 0,1,5,14,30,55,19,68,4,85,185,64,208,39,235,10,266,555,231,592,192,

%T 633,149,678,102,727,51,780,1564,723,1623,662,1686,597,1753,528,1824,

%U 455,1899,378,1978,297,2061,212,2148,123,2239,4448,2144,4545

%N a(0) = 0; a(n) = a(n-1) - n^2 if positive and new, otherwise a(n) = a(n-1) + n^2.

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

%H Samuel Harkness, <a href="/A053461/b053461.txt">Table of n, a(n) for n = 0..10000</a>

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

%t a = {0, 1}; Do[If[a[[-1]] - n^2 >= 0 && Position[a, a[[-1]] - n^2] == {}, a = Append[a, a[[-1]] - n^2], a = Append[a, a[[-1]] + n^2]], {n, 2, 49}]; Print[a] (* _Samuel Harkness_, Sep 20 2022 *)

%o (PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; my(sa = Set(va)); for (n=2, nn, my(x = va[n-1] - n^2); if ((x>0) && !setsearch(sa, x), va[n] = x, va[n] = va[n-1] + n^2); sa = Set(va);); concat(0, va);} \\ _Michel Marcus_, Sep 26 2022

%Y Cf. A076042 ('Easy Recamán transform' of the squares), A064365 ('Recamán transform' of the primes).

%K nonn,hear

%O 0,3

%A _N. J. A. Sloane_, Feb 09 2002

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 24 19:31 EDT 2024. Contains 371962 sequences. (Running on oeis4.)