The OEIS is supported by the many generous donors to the OEIS Foundation.

 Hints (Greetings from The On-Line Encyclopedia of Integer Sequences!)
 A248939 Table read by rows: row n lists the wrecker ball sequence starting with n, or contains -1 if 0 is never reached.. 9
 0, 1, 0, 2, 1, -1, -4, 0, 3, 2, 0, 4, 3, 1, -2, 2, -3, -9, -16, -8, -17, -7, -18, -6, 7, 21, 6, -10, -27, -45, -26, -46, -25, -47, -24, 0, 5, 4, 2, -1, 3, -2, -8, -15, -7, -16, -6, -17, -5, 8, 22, 7, -9, -26, -44, -25, -45, -24, -46, -23, 1, 26, 0, 6, 5, 3 (list; graph; refs; listen; history; text; internal format)
 OFFSET 0,4 COMMENTS The wrecker ball sequence starting with n is defined by x[1] = n, and while x[k] is nonzero, x[k+1] = x[k] + s(k)*k, where s(k) = sign(x[k]) if the "candidate" x[k] - sign(x[k])*k had occurred earlier as some x[j], j <= k, and s(k) = -sign(x[k]) else. (This means, from x[k] one moves a distance of k towards the direction of 0 if the result did not occur earlier, or else in the opposite direction.) - M. F. Hasler, Mar 18 2019 A228474(n) + 1 gives the length of row n. It is currently unproved whether all rows are of finite length. In particular, the length of row 11281 is unknown but larger than 32*10^9. - M. F. Hasler, Mar 18 2019 Hans Havermann, running code from Hugo van der Sanden, has found that row 11281 has length 3285983871527. - N. J. A. Sloane, Mar 22 2019 LINKS Reinhard Zumkeller, Rows n = 0..16 of triangle, flattened Gordon Hamilton, Wrecker Ball Sequences, Video, 2013 Index entries for sequences related to Recamán's sequence FORMULA T(n,0) = n; There are three cases for k > 0: case T(n,k-1) > 0: if T(n,k-1) - k != T(n,m), for all m=0..k-1 then T(n,k) = T(n,k-1) - k, otherwise T(n,k) = T(n,k-1) + k, case T(n,k-1) < 0: if T(n,k-1) + k != T(n,m), for all m=0..k-1 then T(n,k) = T(n,k-1) + k, otherwise T(n,k) = T(n,k-1) - k, case T(n,k-1) = 0: T(n,k) = 0; row ends, i.e., k = A228474(n). EXAMPLE 0: 0; 1: 1 0; 2: 2 1 -1 -4 0; 3: 3 2 0; 4: 4 3 1 -2 2 -3 -9 -16 -8 -17 -7 -18 -6 7 21 6 -10 -27 -45 -26 -46 -25 -47 -24 0; 5: 5 4 2 -1 3 -2 -8 -15 -7 -16 -6 -17 -5 8 22 7 -9 -26 -44 -25 -45 -24 -46 -23 1 26 0; 6: 6 5 3 0; 7: 7 6 4 1 -3 2 -4 3 -5 -14 -24 -13 -1 12 -2 13 29 . . . . . . . 1730 3445 1729 3446 1728 3447 1727 3448 1726 3449 1725 0; 8: 8 7 5 2 -2 3 -3 4 -4 -13 -23 -12 0; 9: 9 8 6 3 -1 4 -2 5 -3 -12 -22 -11 1 14 0. MATHEMATICA row[0] = 0; row[n_] := Module[{b}, b[0] = n; b[k_] /; b[k-1] > 0 := b[k] = If[AllTrue[ Range[0, k-1], b[k-1] - k != b[#]&], b[k-1] - k, b[k-1] + k]; b[k_] /; b[k-1] < 0 := b[k] = If[AllTrue[Range[0, k-1], b[k-1] + k != b[#]&], b[k-1] + k, b[k-1] - k]; b[k_] /; b[k-1] == 0 := b[k] = 0; Reap[k = 0; While[b[k] != 0, Sow[b[k++]]]; Sow[0]][[2, 1]]]; row /@ Range[0, 16] // Flatten (* Jean-François Alcover, Sep 27 2019 *) PROG (Haskell) import Data.IntSet (singleton, member, insert) a248939 n k = a248939_tabf !! n !! k a248939_tabf = map a248939_row [0..] a248939_row n = n : wBall 1 n (singleton n) where wBall _ 0 _ = [] wBall k x s = y : wBall (k + 1) y (insert y s) where y = x + (if (x - j) `member` s then j else -j) j = k * signum x (PARI) row(n)={my(M=Map(), L=List(), k=0); while(n, k++; listput(L, n); mapput(M, n, 1); my(t=if(n>0, -k, +k)); n+=if(mapisdefined(M, n+t), -t, t)); listput(L, 0); Vec(L)} for(n=0, 6, print(row(n))) \\ Andrew Howroyd, Mar 01 2018 (Python) def A248939_row(n): seen = {n}; orbit = [n]; c = 0 while n != 0: ++c; s = c if n>0 else -c; n += s if n-s in seen else -s seen.add(n); orbit.append(n) return orbit # M. F. Hasler, Mar 18 2019 (C++) #include A248939_row(long n) { int c=0, s; for(std::map seen; n; n += seen[n-(s=n>0?c:-c)] ? s:-s) { std::cout<

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.

Last modified February 28 20:40 EST 2024. Contains 370400 sequences. (Running on oeis4.)