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.

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