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.

User: Jonathon Priestley

Jonathon Priestley's wiki page.

Jonathon Priestley has authored 2 sequences.

A362652 Expansion of g.f. x*(-2 - 2*x + x^2 - x^3)/((1 + x)^2 *(-1 + x)^3).

Original entry on oeis.org

2, 4, 7, 12, 16, 24, 29, 40, 46, 60, 67, 84, 92, 112, 121, 144, 154, 180, 191, 220, 232, 264, 277, 312, 326, 364, 379, 420, 436, 480, 497, 544, 562, 612, 631, 684, 704, 760, 781, 840, 862, 924, 947, 1012, 1036, 1104, 1129, 1200, 1226, 1300, 1327
Offset: 1

Author

Jonathon Priestley, Apr 28 2023

Keywords

Comments

a(n) gives the number of vertices encountered along the shortest walk that encounters every edge at least once on the graph with n vertices where the graph is both complete and every node also has an edge to itself.
a(n) can be thought of as the length of a list made up using n distinct elements where every element is next to every other element (including a copy of itself) at least once. Such a list could be used forwards and backward when kerning a font as a way to minimize the number of characters typed in total.

Examples

			G.f.: 2*x + 4*x^2 + 7*x^3 + 12*x^4 + 16*x^5 + 24*x^6 + 29*x^7 + 40*x^8 + 46*x^9 + ...
		

Crossrefs

Cf. A053439.

Programs

  • Mathematica
    CoefficientList[Series[x(-2-2x+x^2-x^3)/((1+x)^2(-1+x)^3), {x, 0, 50}], x]
    (* or *)
    LinearRecurrence[{1, 2, -2, -1, 1}, {2, 4, 7, 12, 16}, 50]
  • Python
    def a(n: int): return n + (n & 1) + n * ( n >> 1 )

Formula

a(n) = n + (n mod 2) + (n * (n - (n mod 2)))/2.
a(2*n) = 2*n + 2*n^2;
a(2*n - 1) = 1 - n + 2*n^2.
E.g.f.: (2 + x)*(exp(x)*x + sinh(x))/2. - Stefano Spezia, May 07 2023

A343383 Length of the preperiodic part of 'Roll and Subtract' trajectory of n.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6, 2, 1, 2, 6, 4, 5, 3, 3, 5, 4, 6
Offset: 0

Author

Jonathon Priestley, Apr 12 2021

Keywords

Comments

'Roll and Subtract' is defined by x -> |x - roll(x)|, where roll(x) takes the first digit of a number and moves it to the back (rolls it around to the back).
Differs from A151962 first at n=101. - R. J. Mathar, May 07 2021

Examples

			a(119) = 4 since |119 - 191| = 72 -> |72 - 27| = 45 -> |45 - 54| = 9 -> |9 - 9| = 0. The value a(0) maps to 0, so the sequence ends there after 4 values have been traversed.
a(12737) = 1 since |12737 - 27371| = 14634 -> |14634 - 46341| = 31707 -> |31707 - 17073| = 14634. Since 14634 is already in the sequence, the sequence ends there.
		

Crossrefs

Cf. A072137 (reverse and subtract).

Programs

  • Mathematica
    Array[Function[w, LengthWhile[w, # != Last[w] &]]@ NestWhileList[Abs[# - FromDigits@ RotateLeft@ IntegerDigits[#]] &, #, Unequal, All] &, 105, 0] (* Michael De Vlieger, Apr 13 2021 *)
  • Python
    def roll(n):
        """ Moves first digit to the back """
        s = str(n)
        return int(s[1:] + s[0])
    def backtrack(past, length, offset, dct):
        """ Goes through every value passed and adds it and it's length to the dictionary """
        if length == 0:
            for elem in past:
                dct[elem] = 0
        i = 0
        while length > 0:
            n = past[i]
            dct[n] = length + offset
            i += 1
            length -= 1
        return dct
    def a(n, dct):
        past = []
        length = 0
        while (n not in dct):
            past.append(n)
            length += 1
            n = abs(n - roll(n))
            if n in past: # For duplicates
                length = past.index(n)
                dct = backtrack(past, length, 0, dct)
                return dct, length
        offset = dct[n]
        dct = backtrack(past, length, offset, dct)
        length += offset
        return dct, length
    dct = {}
    sequence = []
    i = 1
    while i < 1000:
        out = a(i, dct)
        dct = out[0]
        sequence.append(out[1])
        i += 1