login
This site is supported by donations 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
0, 1, 4, 2, 24, 26, 3, 1725, 12, 14, 4, 26, 123, 125, 15, 5, 119, 781802, 20, 22, 132896, 6, 51, 29, 31, 1220793, 23, 25, 7, 429, 8869123, 532009, 532007, 532009, 532011, 26, 8, 94, 213355, 213353, 248, 33, 31, 33, 1000, 9, 144, 110, 112, 82, 84, 210, 60, 34 (list; graph; refs; listen; history; text; internal format)
OFFSET

0,3

COMMENTS

This is a Recamán-like sequence (cf. A005132).

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

a(n) + 1 = length of row n in tables A248939 and A248973. - Reinhard Zumkeller, Oct 20 2014

Hans Havermann, running code from Hugo van der Sanden, has found that a(11281) is 3285983871526. - N. J. A. Sloane, Mar 22 2019

If a(n) != -1 then floor((a(n)-1)/2)+n is odd. - Robert Gerbicz, Mar 28 2019

LINKS

Jon E. Schoenfield, Table of n, a(n) for n = 0..10000

Gordon Hamilton, Wrecker Ball Sequences, 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]

Hans Havermann, Table of n, a(n) for n = 0..36617

Hans Havermann, Log-plot of terms through n = 36617

Hans Havermann, Sharp peaks and high plateaus An overview of large knowns and unknowns up to index 10^6.

Index entries for sequences related to Recamán's sequence

EXAMPLE

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

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

MAPLE

# To compute at most the first M steps of the trajectory of n:

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

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

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

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

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

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

    s:=sign(h);

  od;

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

end;  # N. J. A. Sloane, Mar 07 2019

MATHEMATICA

{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 *)

PROG

(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]

(Haskell) a228474 = subtract 1 . length . a248939_row  -- Reinhard Zumkeller, Oct 20 2014

(C++) #include <map>

  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

(Julia)

function A228474(n)

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

    while position != 0

        k += 1

        step = position > 0 ? k : -k

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

        push!(beenhere, position)

    end

    return length(beenhere) - 1

end

println([A228474(n) for n in 0:16]) # Peter Luschny, Mar 24 2019

CROSSREFS

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

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

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

Sequence in context: A030211 A134461 A298593 * A058167 A140331 A095896

Adjacent sequences:  A228471 A228472 A228473 * A228475 A228476 A228477

KEYWORD

walk,nonn,look,hear

AUTHOR

Gordon Hamilton, Aug 23 2013

EXTENSIONS

More terms from Jon E. Schoenfield, Jan 10 2014

Escape clause in definition added by N. J. A. Sloane, Mar 07 2019

Edited by M. F. Hasler, Mar 18 2019

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 13 18:57 EDT 2019. Contains 327981 sequences. (Running on oeis4.)