cp's OEIS Frontend

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.

Showing 1-8 of 8 results.

A248973 Table read by rows: row n contains the partial sums of the wrecker ball sequences starting with n, cf. A248939.

Original entry on oeis.org

0, 1, 1, 2, 3, 2, -2, -2, 3, 5, 5, 4, 7, 8, 6, 8, 5, -4, -20, -28, -45, -52, -70, -76, -69, -48, -42, -52, -79, -124, -150, -196, -221, -268, -292, -292, 5, 9, 11, 10, 13, 11, 3, -12, -19, -35, -41, -58, -63, -55, -33, -26, -35, -61, -105, -130, -175, -199, -245, -268, -267, -241, -241
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 20 2014

Keywords

Comments

A228474(n) + 1 = length of row n;
row n = partial sums of row n in A248939;
T(n,A228474(n)) = A248961(n).

Crossrefs

Cf. A228474 (row lengths - 1), A248961 (right edge).

Programs

  • Haskell
    a248973 n k = a248973_tabf !! n !! k
    a248973_row n = a248973_tabf !! n
    a248973_tabf = map (scanl1 (+)) a248939_tabf

Formula

T(n,0) = n; T(n,k) = T(n,k-1) + A248939(n,k) for k=1..A228474(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.

Original entry on oeis.org

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
Offset: 0

Views

Author

Gordon Hamilton, Aug 23 2013

Keywords

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

Examples

			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
		

Crossrefs

Cf. A248939 (rows = the full sequences), A248961 (row sums), A248973 (partial sums per row), A248952 (min per row), A248953 (max per row).
Cf. also A248940 (row 7), A248941 (row 17), A248942 (row 20).
Cf. also A000217, A005132 (Recamán).

Programs

  • Haskell
    a228474 = subtract 1 . length . a248939_row  -- Reinhard Zumkeller, Oct 20 2014
    (C++) #include 
      int A228474(long n) { int c=0, s; for(std::map 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
  • 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 *)
  • 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]
    

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

A248952 Smallest term in wrecker ball sequence starting with n.

Original entry on oeis.org

0, 0, -4, 0, -47, -46, 0, -6362, -23, -22, 0, -32, -471, -470, -29, 0, -218, -4843985, -39, -38, -657367, 0, -101, -57, -56, -7609937, -45, -44, 0, -736, -56168428, -3113136, -3113135, -3113134, -3113133, -51, 0, -190, -1213998, -1213997, -495, -62, -61, -60
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

Starting at n, a(n) is the minimum value reached according to the following rules. On the k-th step (k = 1, 2, 3, ...) move a distance of k in the direction of zero. If the number landed on has been landed on before, move a distance of k away from zero instead. See A228474 and A248939. - David Nacin, Mar 15 2019
It is currently unproved whether all orbits are finite, and therefore unclear whether all a(n) are well defined. In particular, the orbit of n = 11281 is of unknown length, but is certainly greater than 32*10^9. - M. F. Hasler, Mar 18 2019

Examples

			a(0) = min{0} = 0;
a(1) = min{1,0} = 0;
a(2) = min{2,1,-1,-4,0} = -4;
a(3) = min{3,2,0} = 0;
a(4) = min{4,3,1,-2,2,-3,-9,-16,-8,-17,-7,-18,-6,7,21,6,-10,-27,...} = -47;
a(5) = min{5,4,2,-1,3,-2,-8,-15,-7,-16,-6,-17,-5,8,22,7,-9,-26,...} = -46;
a(6) = min{6,5,3,0} = 0;
a(7) = min{7,6,4,1,-3,2,-4,3,-5,-14,-24,-13,-1,12,-2,13,29,46,...} = -6362;
a(8) = min{8,7,5,2,-2,3,-3,4,-4,-13,-23,-12,0} = -23;
a(9) = min{9,8,6,3,-1,4,-2,5,-3,-12,-22,-11,1,14,0} = -22.
		

Crossrefs

Cf. A228474 (main entry for wrecker ball sequences).

Programs

  • Haskell
    import Data.IntSet (singleton, member, insert, findMin, findMax)
    a248952 n = a248952_list !! n
    (a248952_list, a248953_list) = unzip $
       map (\x -> minmax 1 x $ singleton x) [0..] where
       minmax _ 0 s = (findMin s, findMax s)
       minmax k x s = minmax (k + 1) y (insert y s) where
                             y = x + (if (x - j) `member` s then j else -j)
                             j = k * signum x
    
  • Python
    #This and sequences A324660-A324692 generated by manipulating this trip function
    #spots - positions in order with possible repetition
    #flee - positions from which we move away from zero with possible repetition
    #stuck - positions from which we move to a spot already visited with possible repetition
    def trip(n):
        stucklist = list()
        spotsvisited = [n]
        leavingspots = list()
        turn = 0
        forbidden = {n}
        while n != 0:
            turn += 1
            sign = n // abs(n)
            st = sign * turn
            if n - st not in forbidden:
                n = n - st
            else:
                leavingspots.append(n)
                if n + st in forbidden:
                    stucklist.append(n)
                n = n + st
            spotsvisited.append(n)
            forbidden.add(n)
        return {'stuck':stucklist, 'spots':spotsvisited,
                    'turns':turn, 'flee':leavingspots}
    #Actual sequence
    def a(n):
        d = trip(n)
        return min(d['spots'])
    # David Nacin, Mar 15 2019
    
  • Python
    def A248952(n):
        return min(A248939_row(n)); # M. F. Hasler, Mar 18 2019
    (C++) #include
    long A248952(long n) { long c=0, s, m=0; for(std::map seen; n; n += seen[n-(s=n>0?c:-c)] ? s:-s) { if(nM. F. Hasler, Mar 18 2019

Formula

a(n) = smallest term in row n of triangle A248939;
a(A000217(n)) = 0; a(A014132(n)) < 0.

Extensions

Edited by M. F. Hasler, Mar 18 2019

A248953 Largest term in wrecker ball sequence starting with n.

Original entry on oeis.org

0, 1, 2, 3, 21, 26, 6, 6843, 8, 14, 10, 72, 365, 366, 14, 15, 352, 4674389, 18, 22, 891114, 21, 102, 23, 31, 7856204, 26, 27, 28, 1700, 61960674, 3702823, 3702824, 3702825, 3702826, 35, 36, 370, 1047903, 1047904, 596, 41, 42, 43, 2976, 45, 341, 260, 261, 123
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

Starting at n, a(n) is the maximum reached according to the following rules: Unless 0 has been reached, on the k-th step (k = 1, 2, 3, ...) move a distance of k in the direction of zero. If the result has already occurred before, move a distance of k away from zero instead. See A228474 and A248939. - David Nacin, Mar 15 2019
It is currently unproved that all orbits are finite, and therefore unclear whether all a(n) are well defined. In particular, the orbit of n = 11281 is of unknown length > 32*10^9 steps. - M. F. Hasler, Mar 18 2019

Examples

			a(0) = max {0} = 0;
a(1) = max {1,0} = 1;
a(2) = max {2,1,-1,-4,0} = 2;
a(3) = max {3,2,0} = 3;
a(4) = max {4,3,1,-2,2,-3,-9,-16,-8,-17,-7,-18,-6,7,21,6,-10,-27,...} = 21;
a(5) = max {5,4,2,-1,3,-2,-8,-15,-7,-16,-6,-17,-5,8,22,7,-9,-26,...} = 26;
a(6) = max {6,5,3,0} = 6;
a(7) = max {7,6,4,1,-3,2,-4,3,-5,-14,-24,-13,-1,12,-2,13,29,46,...} = 6843;
a(8) = max {8,7,5,2,-2,3,-3,4,-4,-13,-23,-12,0} = 8;
a(9) = max {9,8,6,3,-1,4,-2,5,-3,-12,-22,-11,1,14,0} = 14.
		

Crossrefs

Cf. A248939 (entire orbit of n), A248952 (minimum of the orbit), A000217, A228474 (length of orbits - 1: main entry for wrecker ball sequences).

Programs

  • Haskell
    a248953 n = a248953_list !! n
    -- See A248952 for definition of a248953_list.
    
  • Python
    #This and sequences A324660-A324692 generated by manipulating this trip function
    #spots - positions in order with possible repetition
    #flee - positions from which we move away from zero with possible repetition
    #stuck - positions from which we move to a spot already visited with possible repetition
    def trip(n):
        stucklist = list()
        spotsvisited = [n]
        leavingspots = list()
        turn = 0
        forbidden = {n}
        while n != 0:
            turn += 1
            sign = n // abs(n)
            st = sign * turn
            if n - st not in forbidden:
                n = n - st
            else:
                leavingspots.append(n)
                if n + st in forbidden:
                    stucklist.append(n)
                n = n + st
            spotsvisited.append(n)
            forbidden.add(n)
        return {'stuck':stucklist, 'spots':spotsvisited,
                'turns':turn, 'flee':leavingspots}
    #Actual sequence
    def a(n):
        d = trip(n)
        return max(d['spots'])
    # David Nacin, Mar 15 2019
    (C++) #include
    long A248953(long n) { long c=0, s, m=n; for(std::map seen; n; n += seen[n-(s=n>0?c:-c)] ? s:-s) { if(n>m) m=n; seen[n]=true; ++c; } return m; } // M. F. Hasler, Mar 18 2019

Formula

a(n) = largest term in row n of triangle A248939.
a(A000217(n)) = A000217(n).

Extensions

Edited by M. F. Hasler, Mar 18 2019

A248940 Wrecker ball sequence starting with 7.

Original entry on oeis.org

7, 6, 4, 1, -3, 2, -4, 3, -5, -14, -24, -13, -1, 12, -2, 13, 29, 46, 28, 9, -11, 10, -12, 11, 35, 60, 34, 61, 33, 62, 32, 63, 31, 64, 30, 65, 101, 138, 100, 139, 99, 58, 16, -27, 17, -28, 18, -29, 19, -30, 20, -31, 21, -32, 22, -33, 23, -34, 24, -35, 25, -36
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

Finite sequence with A228474(7) + 1 = 1726 terms;
row 7 of table A248939: a(n) = A248939(7,n) for n = 0..1725;
A248952(7) = -6362 <= a(n) <= 6843 = A248953(7).

Crossrefs

Cf. A248939, A228474, A248941 (start with 17), A248942 (start with 20).

Programs

  • Haskell
    a248940 n = a248940_list !! n
    a248940_list = a248939_row 7

A248941 Wrecker ball sequence starting with 17.

Original entry on oeis.org

17, 16, 14, 11, 7, 2, -4, 3, -5, 4, -6, 5, -7, 6, -8, -23, -39, -22, -40, -21, -1, 20, -2, 21, -3, 22, 48, 75, 47, 18, -12, 19, -13, -46, -80, -45, -9, 28, -10, 29, -11, 30, 72, 115, 71, 26, -20, 27, 75, 124, 74, 23, -29, 24, -30, 25, -31, -88, -146, -87
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

This is a finite sequence, containing exactly A228474(17) + 1 = 781803 terms.
This is row 17 of table A248939: a(n) = A248939(17,n) for n = 0..781802;
A248952(17) = -4843985 <= a(n) <= 4674389 = A248953(17).

Crossrefs

Cf. A248939, A228474, A248940 (start with 7), A248942 (start with 20).

Programs

  • Haskell
    a248941 n = a248941_list !! n
    a248941_list = a248939_row 17

A248942 Wrecker ball sequence starting with 20.

Original entry on oeis.org

20, 19, 17, 14, 10, 5, -1, 6, -2, 7, -3, 8, -4, 9, -5, -20, -36, -19, -37, -18, 2, 23, 1, -22, -46, -21, -47, -74, -102, -73, -43, -12, -44, -11, -45, -10, 26, 63, 25, -14, -54, -13, 29, 72, 28, -17, -63, -16, 32, 81, 31, 82, 30, -23, -77, -132, -76, -133
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

Finite sequence with A228474(20) + 1 = 132897 terms;
row 20 of table A248939: a(n) = A248939(20,n) for n = 0..132896;
A248952(20) = -657367 <= a(n) <= 891114 = A248953(20).

Crossrefs

Cf. A248939, A228474, A248940 (start with 7), A248941 (start with 17).

Programs

  • Haskell
    a248942 n = a248942_list !! n
    a248942_list = a248939_row 20

A248961 Sums of wrecker ball sequences starting with n.

Original entry on oeis.org

0, 1, -2, 5, -292, -241, 14, -437861, -28, -1, 30, 313, -4472, -4223, -2, 55, 3252, -214246256269, -70, -27, 5260887648, 91, -538, -193, -132, -864538549823, -22, 27, 140, 40053, 53088613819206, 86166834699, 86167898716, 86168962733, 86170026754, 49, 204
Offset: 0

Views

Author

Reinhard Zumkeller, Oct 18 2014

Keywords

Comments

a(n) = A248973(n, A228474(n)) = sum of row n in triangle A248939;
a(A000217(n)) = A000330(n).

Examples

			a(1) = 1+0 = 1;
a(2) = 2+1-1-4+0 = -2;
a(3) = 3+2+0 = 5;
a(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 = -292;
a(5) = 5+4+2-1+3-2-8-15-7-16-6-17-5+8+22+7-9-26-44-25-45-24-46-... = -241;
a(6) = 6+5+3+0 = 14;
a(7) = 7+6+4+1-3+2-4+3-5-14-24-13-1+12-2+13+29+46+28+9-11+10-... = -437861;
a(8) = 8+7+5+2-2+3-3+4-4-13-23-12+0 = -28;
a(9) = 9+8+6+3-1+4-2+5-3-12-22-11+1+14+0 = -1.
		

Crossrefs

Programs

  • Haskell
    import Data.IntSet (singleton, member, insert)
    a248961 n = addup 1 n 0 $ singleton n where
       addup  0 sum  = sum
       addup k x sum s = addup (k + 1) y (sum + x) (insert y s) where
                         y = x + (if (x - j) `member` s then j else -j)
                         j = k * signum x
    (C++) #include
    long A248961(long n) { long c=0, d, S=n; for(std::set A; n; A.insert(n), S += n += A.count(n - (d = n>0 ? c : -c)) ? d : -d) ++c; return S; } // M. F. Hasler, Mar 19 2019
    
  • PARI
    A248961(n,A=[n],c,S=n)={while( n+=sign(n)*if(setsearch(A,n-sign(n)*c+=1), c, -c), A=setunion(A,[n]); S+=n); S} \\ M. F. Hasler, Mar 19 2019
    
  • Python
    def A248961(n):
      A = {n}; c = 0; S = 0
      while n != 0:
        ++c; s = c if n>0 else -c; n += s if n-s in A else -s; A.add(n); S += n
      return S # M. F. Hasler, Mar 19 2019
Showing 1-8 of 8 results.