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!)
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. 42

%I #105 May 16 2019 01:32:32

%S 0,1,4,2,24,26,3,1725,12,14,4,26,123,125,15,5,119,781802,20,22,132896,

%T 6,51,29,31,1220793,23,25,7,429,8869123,532009,532007,532009,532011,

%U 26,8,94,213355,213353,248,33,31,33,1000,9,144,110,112,82,84,210,60,34

%N 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 This is a Recamán-like sequence (cf. A005132).

%C The n-th triangular number A000217(n) has a(A000217(n)) = n.

%C a(n) + 1 = length of row n in tables A248939 and A248973. - _Reinhard Zumkeller_, Oct 20 2014

%C _Hans Havermann_, running code from _Hugo van der Sanden_, has found that a(11281) is 3285983871526. - _N. J. A. Sloane_, Mar 22 2019

%C If a(n) != -1 then floor((a(n)-1)/2)+n is odd. - _Robert Gerbicz_, Mar 28 2019

%H Jon E. Schoenfield, <a href="/A228474/b228474.txt">Table of n, a(n) for n = 0..10000</a>

%H 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 Hans Havermann, <a href="/A228474/a228474.txt">Table of n, a(n) for n = 0..36617</a>

%H Hans Havermann, <a href="/A228474/a228474.png">Log-plot of terms through n = 36617</a>

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

%e a(2) = 4 because 2 -> 1 -> -1 -> -4 -> 0.

%e 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 # To compute at most the first M steps of the trajectory of n:

%p f:=proc(n) local M,i,j,traj,h;

%p M:=200; traj:=[n]; h:=n; s:=1;

%p for i from 1 to M do j:=h-s*i;

%p if member(j,traj,'p') then s:=-s; fi;

%p h:=h-s*i; traj:=[op(traj),h];

%p if h=0 then return("steps, trajectory =", i, traj); fi;

%p s:=sign(h);

%p od;

%p lprint("trajectory so far = ", traj); error("Need to increase M");

%p end; # _N. J. A. Sloane_, Mar 07 2019

%t {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 (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 (Haskell) a228474 = subtract 1 . length . a248939_row -- _Reinhard Zumkeller_, Oct 20 2014

%o (C++) #include <map>

%o 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 (Julia)

%o function A228474(n)

%o k, position, beenhere = 0, n, [n]

%o while position != 0

%o k += 1

%o step = position > 0 ? k : -k

%o position += (position - step) in beenhere ? step : -step

%o push!(beenhere, position)

%o end

%o return length(beenhere) - 1

%o end

%o println([A228474(n) for n in 0:16]) # _Peter Luschny_, Mar 24 2019

%Y Cf. A248939 (rows = the full sequences), A248961 (row sums), A248973 (partial sums per row), A248952 (min per row), A248953 (max per row), A001532.

%Y Cf. also A248940 (row 7), A248941 (row 17), A248942 (row 20).

%Y Cf. also A000217, A005132 (Recamán).

%K walk,nonn,look,hear

%O 0,3

%A _Gordon Hamilton_, Aug 23 2013

%E More terms from _Jon E. Schoenfield_, Jan 10 2014

%E Escape clause in definition added by _N. J. A. Sloane_, Mar 07 2019

%E Edited by _M. F. Hasler_, Mar 18 2019

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 22:17 EDT 2024. Contains 371964 sequences. (Running on oeis4.)