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: Matthew Malone

Matthew Malone's wiki page.

Matthew Malone has authored 6 sequences.

A346707 "Look once to the left" sequence, omitting a(k) for each iteration k, starting with 1,2 (see example).

Original entry on oeis.org

1, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 2, 1, 1, 2
Offset: 1

Author

Matthew Malone, Jul 29 2021

Keywords

Comments

The ratio of number of 2's to number of 1's appears to converge to 1.3985918...

Examples

			Begin with [1, 2].
Iteration 1: append to self, omitting term 1: [1, 2] + [2] = [1, 2, 2].
Iteration 2: append to self, omitting term 2: [1, 2, 2] + [1, 2] = [1, 2, 2, 1, 2].
Iteration 3: append to self, omitting term 3: [1, 2, 2, 1, 2] + [1, 2, 1, 2] = [1, 2, 2, 1, 2, 1, 2, 1, 2].
		

Crossrefs

Programs

  • Mathematica
    Block[{a = {1, 2}}, Do[a = Join[a, Delete[a, i]], {i, 7}]; a] (* Michael De Vlieger, Aug 04 2021 *)
  • PARI
    a(n) = n-=2; while(n>0, my(k=logint(n,2)); n-=1<Kevin Ryde, Aug 03 2021
  • Python
    def sequence(iterations, start=[1,2]):
      a = start
      for k in range(0, iterations):
        a = a + a[:k] + a[k+1:]
      return a
    

A343453 The number of 3's minus the number of 2's among the first n terms of A342101.

Original entry on oeis.org

0, -1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 1, 0, 1, 1, 2, 2, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 2, 3
Offset: 1

Author

Matthew Malone, Apr 15 2021

Keywords

Comments

It appears that the sequence never goes below -1 and increases without bound.
It appears that if the first appearance of a number x occurs at index n and the first appearance of x+1 appears at index m then m/n approaches 4 as x increases.

Examples

			A342101 = [1, 2, 3, 1, 3, ...]. By the fifth term of A342101 we see 2 terms with value 3, and a single term with value 2, so a(5) = 2 - 1 = 1.
		

Crossrefs

Cf. A342101.

Programs

  • Kotlin
    fun a(iter: Int): List = runningSum(twosVersusThrees(iter))
    fun runningSum(a: List) = a.drop(1).fold(listOf(a[0])) { acc, cur ->
        acc + (acc.last() + cur)
    }
    fun twosVersusThrees(iter: Int): List = removeMiddle(listOf(0,-1,1), iter)
    fun removeMiddle(initial: List, iter: Int): List {
        if (iter < 2) return initial
        val prev = removeMiddle(initial, iter-1)
        return prev + prev.subList(0, (prev.size - 1) / 2) + prev.subList((prev.size + 1) /2, prev.size)
    }
    
  • Mathematica
    Block[{a = {}, s = Nest[Join[#, Drop[#, {(Length[#] + 1)/2}]] &, Range[3], 6], c}, Array[Set[c[#], 0] &, 3]; Do[c[ s[[i]] ]++; AppendTo[a, c[3] - c[2]], {i, Min[Length@ s, 104]}]; a] (* Michael De Vlieger, May 01 2021 *)
  • PARI
    \\ See links.

A338643 Cycle lengths arising from interpreting sequence prefixes as graph node offsets.

Original entry on oeis.org

1, 1, 2, 2, 3, 2, 3, 4, 3, 3, 4, 5, 3, 4, 4, 5, 6, 4, 4, 5, 5, 6, 7, 11, 5, 5, 6, 6, 7, 8, 5, 13, 6, 6, 7, 7, 8, 9, 6, 6, 16, 7, 7, 8, 8, 9, 10, 17, 7, 7, 10, 8, 8, 9, 9, 10, 11, 8, 10, 8, 8, 11, 9, 9, 10, 10, 11, 12, 8, 9, 11, 9, 9, 12, 10, 10, 11, 11, 12, 13
Offset: 1

Author

Matthew Malone, Apr 21 2021

Keywords

Examples

			Start with a(1) = 1. Treat a(1) = 1 as a node pointing 1 space ahead which, wrapping around the end of the length-1 prefix, points to itself. This graph has a cycle length of 1, so a(2) = 1.
Now a(1..2) = [1, 1]. a(1) = 1 points 1 space ahead to a(2) and a(2) = 1 points 1 space ahead and wraps around to a(1), completing a cycle of length 2 so a(3) = 2.
Skipping ahead a bit, a(1..5) = [1, 1, 2, 2, 3]. In this prefix, a(1) = 1 points to a(2) = 1, which points to a(3) = 2, which points to a(5) = 3, which wraps around and points to a(3), for a cycle length of 2, so a(6) = 2.
		

Programs

  • C
    See Links section.
  • Kotlin
    fun graph_sequence(terms: Int): List {
        val a = mutableListOf(1)
        repeat(terms-1) { a += a.loopLength() }
        return a
    }
    fun List.loopLength(): Int {
        val visitedIndices = mutableMapOf()
        var idx = 0
        var counter = 0
        while (idx !in visitedIndices) {
            visitedIndices[idx] = counter++
            idx = (idx + this[idx]) % this.size
        }
        return counter - (visitedIndices[idx] ?: 0)
    }
    

A342101 Remove middle term and append, starting with [1, 2, 3].

Original entry on oeis.org

1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 1, 2, 3, 1, 3, 1, 2, 1, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3, 1, 2, 1, 3, 1, 2, 3, 1, 1, 2, 1, 3, 1, 2, 3, 1, 3
Offset: 1

Author

Matthew Malone, Feb 28 2021

Keywords

Examples

			Start with [1, 2, 3], take that sequence, remove the middle term, 2, and append to the original sequence, yielding [1, 2, 3, 1, 3]. Then repeat this process to give [1, 2, 3, 1, 3, 1, 2, 1, 3], and so on.
		

Crossrefs

Cf. A000051.

Programs

  • Kotlin
    fun A342101(iter: Int): List = removeMiddle(listOf(1,2,3), iter)
    fun removeMiddle(initial: List, iter: Int): List {
      if (iter < 2) return initial
      val prev = removeMiddle(initial, iter-1)
      return prev + prev.subList(0, (prev.size - 1) / 2) + prev.subList((prev.size + 1) /2, prev.size)
    }
    
  • Maple
    T:= proc(n) option remember; `if`(n=1, [$1..3][],
          subsop(2^(n-2)+1=[][], [seq(T(i), i=1..n-1)])[])
        end:
    seq(T(n), n=1..8);  # Alois P. Heinz, Apr 12 2021
  • Mathematica
    Nest[Join[#, Drop[#, {(Length[#] + 1)/2}]] &, Range[3], 6] (* Michael De Vlieger, May 01 2021 *)
  • PARI
    first(n) = { my(v = [1,2,3]); for(i = 1, logint(n-1, 2), cv = v[^(#v + 1)\2]; v = concat(v, cv) ); v } \\ David A. Corneth, Apr 14 2021
    
  • PARI
    \\ Also see links.
  • Python
    def aupton(terms):
      alst = [1, 2, 3]
      while len(alst) < terms:
        alst += alst[:len(alst)//2] + alst[(len(alst)+1)//2:]
      return alst[:terms]
    print(aupton(87)) # Michael S. Branicky, Mar 26 2021
    

A309435 Iteratively replace the product of two sequentially chosen consecutive integers with those integers.

Original entry on oeis.org

1, 2, 3, 4, 5, 2, 3, 7, 8, 9, 5, 2, 11, 3, 4, 13, 14, 15, 16, 17, 18, 19, 4, 5, 3, 7, 2, 11, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 11, 3, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 9, 5, 46, 47, 48, 49, 50, 51, 4, 13, 53, 54, 55, 7, 8, 57, 58, 59, 60
Offset: 1

Author

Matthew Malone, Aug 02 2019

Keywords

Examples

			A_0 = {1,2,3,4,5,...}
A_0(0) * A_0(1) = 1 * 2 = 2, which is not found after A_0(1), so A_1 = A_0.
A_1(1) * A_1(2) = 2 * 3 = 6, which *is* found after A_1(2), so A_2 = {1,2,3,4,5,2,3,7,8,...}
A_2(2) * A_2(3) = 3 * 4 = 12, A_3 = {1,2,3,4,5,2,3,7,8,9,10,11,3,4,13,...}
A_3(3) * A_3(4) = 4 * 5 = 20, A_4 = {1,2,3,4,5,2,3,7,8,9,10,11,3,4,13,...,19,4,5,21,...}
A_4(4) * A_4(5) = 5 * 2 = 10, A_5 = {1,2,3,4,5,2,3,7,8,9,5,2,11,3,4,13,...,19,4,5,21,...}
		

Crossrefs

This sequence is similar to A309503 except it uses multiplication instead of addition.

Programs

  • Kotlin
    fun generate(len: Int): List {
        fun gen_inner(len: Int, level: Int): List {
            if (level < 1) return (1..len).toList()
            val prev = gen_inner(len, level - 1)
            if (level == len) return prev.take(len)
            val (a,b) = prev[level - 1] to prev[level]
            return if (prev.drop(level + 1).contains(a*b)) {
                prev.indexOfFirst { it == a*b }.let { idx ->
                    prev.take(idx) + a + b + prev.drop(idx + 1)
                }
            } else prev
        }
        return gen_inner(len,len)
    }
    
  • Mathematica
    T = Range[100]; Do[p = T[[i]] T[[i + 1]]; Do[If[T[[j]] == p, T = Join[ T[[;; j-1]], {T[[i]], T[[i+1]]}, T[[j+1 ;;]]]; Break[]], {j, i+2, Length@ T}], {i, Length@T}]; T (* Giovanni Resta, Sep 20 2019 *)
  • PARI
    a = vector(92, k, k); for (n=1, #a, print1 (a[n] ", "); s=a[n]*a[n+1]; for (k=n+2, #a, if (a[k]==s, a=concat([a[1..k-1], a[n..n+1], a[k+1..#a]]); break))) \\ Rémy Sigrist, Aug 03 2019

Formula

To generate the sequence, start with the integers, A_0={1,2,3,4,5,...}. To generate A_{n+1} calculate x = A_n(n) * A_n(n+1). Replace the next instance of x in A_n (after A_n(n+1)) with A_n(n), A_n(n+1). The limit of this process gives the sequence.

A309503 Iteratively replace the sum of two sequentially chosen consecutive integers with those integers.

Original entry on oeis.org

1, 2, 1, 2, 4, 5, 2, 4, 5, 2, 8, 4, 5, 2, 8, 11, 8, 4, 13, 14, 15, 16, 4, 13, 4, 14, 8, 11, 16, 4, 8, 13, 22, 23, 24, 4, 8, 13, 4, 14, 8, 13, 14, 24, 4, 14, 15, 30, 15, 16, 24, 8, 33, 34, 13, 22, 36, 37, 14, 24, 8, 13, 4, 14, 24, 16, 41, 42, 8, 13, 22, 44
Offset: 1

Author

Matthew Malone, Aug 05 2019

Keywords

Examples

			A_0 = {1,2,3,4,5,...}.
A_0(0) + A_0(1) = 1 + 2 = 3, which is found after A_0(1), so A_1 = {1,2,1,2,4,5,...}.
A_1(1) + A_1(2) = 2 + 1 = 3, which is *not* found after A_1(2), so A_2 = A_1.
A_2(2) + A_2(3) = 1 + 2 = 3, A_3 = A_2.
A_3(3) + A_3(4) = 2 + 4 = 6, A_4 = {1,2,1,2,4,5,2,4,7,8,9,10,...}.
A_4(4) + A_4(5) = 4 + 5 = 9, A_5 = {1,2,1,2,4,5,2,4,7,8,4,5,10,...}.
		

Crossrefs

This sequence is similar to A309435 except it uses addition instead of multiplication.

Programs

  • Kotlin
    fun generate(len: Int): List {
        fun gen_inner(len: Int, level: Int): List {
            if (level < 1) return (1..len).toList()
            val prev = gen_inner(len, level - 1)
            if (level == len) return prev.take(len)
            val (a, b) = prev[level - 1] to prev[level]
            return if (prev.drop(level + 1).contains(a+b)) {
                prev.indexOfFirst { it == a+b }.let { idx ->
                    prev.take(idx) + a + b + prev.drop(idx + 1)
                }
            } else prev
        }
        return gen_inner(len, len)
    }
    
  • Mathematica
    T = Range[100]; Do[s = T[[i]] + T[[i + 1]]; Do[If[T[[j]] == s, T = Join[ T[[;; j-1]], {T[[i]], T[[i+1]]}, T[[j+1 ;;]]]; Break[]], {j, i+2, Length@ T}], {i, Length@T}]; T (* Giovanni Resta, Sep 20 2019 *)
  • PARI
    a = vector(92, k, k);
    for (n=1, #a-1, s=a[n]+a[n+1]; print1 (a[n] ", "); for (k=n+2, #a - 1, if (a[k]==s, a=concat([a[1..k-1], a[n..n+1], a[k+1..#a]]); break)))

Formula

To generate the sequence, start with the integers, A_0={1,2,3,4,5,...}. To generate A_{n+1} calculate x = A_n(n) + A_n(n+1). Replace the next instance of x in A_n (after A_n(n+1)) with A_n(n), A_n(n+1). The limit of this process gives the sequence.