This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A228474 #107 Feb 01 2025 21:35:00 %S A228474 0,1,4,2,24,26,3,1725,12,14,4,26,123,125,15,5,119,781802,20,22,132896, %T A228474 6,51,29,31,1220793,23,25,7,429,8869123,532009,532007,532009,532011, %U A228474 26,8,94,213355,213353,248,33,31,33,1000,9,144,110,112,82,84,210,60,34 %N A228474 Number of steps required to reach zero in the wrecker ball sequence starting with n: On the k-th step (k = 1, 2, 3, ...) move a distance of k in the direction of zero. If the result has occurred before, move a distance of k away from zero instead. Set a(n) = -1 if 0 is never reached. %C A228474 This is a Recamán-like sequence (cf. A005132). %C A228474 The n-th triangular number A000217(n) has a(A000217(n)) = n. %C A228474 a(n) + 1 = length of row n in tables A248939 and A248973. - _Reinhard Zumkeller_, Oct 20 2014 %C A228474 _Hans Havermann_, running code from _Hugo van der Sanden_, has found that a(11281) is 3285983871526. - _N. J. A. Sloane_, Mar 22 2019 %C A228474 If a(n) != -1 then floor((a(n)-1)/2)+n is odd. - _Robert Gerbicz_, Mar 28 2019 %H A228474 Jon E. Schoenfield, <a href="/A228474/b228474.txt">Table of n, a(n) for n = 0..10000</a> %H A228474 Gordon Hamilton, <a href="http://www.youtube.com/watch?v=mQdNaofLqVc">Wrecker Ball Sequences</a>, Video, 2013. [The sequence is mentioned about 4.5 minutes in to the video. The video begins by discussing A005132. - _N. J. A. Sloane_, Apr 25 2019] %H A228474 Hans Havermann, <a href="/A228474/a228474.txt">Table of n, a(n) for n = 0..36617</a> %H A228474 Hans Havermann, <a href="/A228474/a228474.png">Log-plot of terms through n = 36617</a> %H A228474 Hans Havermann, <a href="http://gladhoboexpress.blogspot.com/2019/04/sharp-peaks-and-high-plateaus.html">Sharp peaks and high plateaus</a> An overview of large knowns and unknowns up to index 10^6. %H A228474 <a href="/index/Rea#Recaman">Index entries for sequences related to Recamán's sequence</a> %e A228474 a(2) = 4 because 2 -> 1 -> -1 -> -4 -> 0. %e A228474 See A248940 for the full 1725-term trajectory of 7. See A248941 for a bigger example, which shows the start of the 701802-term trajectory of 17. - _N. J. A. Sloane_, Mar 07 2019 %p A228474 # To compute at most the first M steps of the trajectory of n: %p A228474 f:=proc(n) local M,i,j,traj,h; %p A228474 M:=200; traj:=[n]; h:=n; s:=1; %p A228474 for i from 1 to M do j:=h-s*i; %p A228474 if member(j,traj,'p') then s:=-s; fi; %p A228474 h:=h-s*i; traj:=[op(traj),h]; %p A228474 if h=0 then return("steps, trajectory =", i, traj); fi; %p A228474 s:=sign(h); %p A228474 od; %p A228474 lprint("trajectory so far = ", traj); error("Need to increase M"); %p A228474 end; # _N. J. A. Sloane_, Mar 07 2019 %t A228474 {0}~Join~Array[-1 + Length@ NestWhile[Append[#1, If[FreeQ[#1, #3], #3, Sign[#1[[-1]] ] (Abs[#1[[-1]] ] + #2)]] & @@ {#1, #2, Sign[#1[[-1]] ] (Abs[#1[[-1]] ] - #2)} & @@ {#, Length@ #} &, {#}, Last@ # != 0 &] &, 16] (* _Michael De Vlieger_, Mar 27 2019 *) %o A228474 (PARI) a(n)={my(M=Map(),k=0); while(n, k++; mapput(M,n,1); my(t=if(n>0, -k, +k)); n+=if(mapisdefined(M,n+t),-t,t)); k} \\ _Charles R Greathouse IV_, Aug 18 2014, revised _Andrew Howroyd_, Feb 28 2018 [Warning: requires latest PARI. - _N. J. A. Sloane_, Mar 09 2019] %o A228474 (Haskell) a228474 = subtract 1 . length . a248939_row -- _Reinhard Zumkeller_, Oct 20 2014 %o A228474 (C++) #include <map> %o A228474 int A228474(long n) { int c=0, s; for(std::map<long,bool> seen; n; n += seen[n-(s=n>0?c:-c)] ? s:-s) { seen[n]=true; ++c; } return c; } // _M. F. Hasler_, Mar 18 2019 %o A228474 (Julia) %o A228474 function A228474(n) %o A228474 k, position, beenhere = 0, n, [n] %o A228474 while position != 0 %o A228474 k += 1 %o A228474 step = position > 0 ? k : -k %o A228474 position += (position - step) in beenhere ? step : -step %o A228474 push!(beenhere, position) %o A228474 end %o A228474 return length(beenhere) - 1 %o A228474 end %o A228474 println([A228474(n) for n in 0:16]) # _Peter Luschny_, Mar 24 2019 %Y A228474 Cf. A248939 (rows = the full sequences), A248961 (row sums), A248973 (partial sums per row), A248952 (min per row), A248953 (max per row). %Y A228474 Cf. also A248940 (row 7), A248941 (row 17), A248942 (row 20). %Y A228474 Cf. also A000217, A005132 (Recamán). %K A228474 walk,nonn,look,hear %O A228474 0,3 %A A228474 _Gordon Hamilton_, Aug 23 2013 %E A228474 More terms from _Jon E. Schoenfield_, Jan 10 2014 %E A228474 Escape clause in definition added by _N. J. A. Sloane_, Mar 07 2019 %E A228474 Edited by _M. F. Hasler_, Mar 18 2019