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-2 of 2 results.

A364603 Lexicographically earliest sequence where after the m-th appearance of term z, it is banned from re-appearing in the next m*z terms.

Original entry on oeis.org

1, 2, 1, 3, 2, 1, 4, 3, 5, 1, 2, 4, 6, 7, 1, 3, 5, 2, 8, 6, 1, 4, 7, 9, 10, 3, 2, 1, 5, 8, 11, 12, 6, 9, 4, 1, 10, 2, 3, 7, 13, 14, 11, 15, 1, 5, 8, 12, 16, 17, 2, 4, 6, 9, 1, 3, 13, 10, 14, 15, 18, 7, 19, 20, 21, 1, 2, 5, 11, 16, 17, 8, 4, 12, 3, 22, 23, 1, 6, 18, 24, 9, 19, 2, 13, 20, 21, 14
Offset: 1

Views

Author

Rok Cestnik, Jul 29 2023

Keywords

Examples

			a(n)   ban 1  2  3  4  5  6  7 ...
 1         |  |  |  |  |  |  |
 2         x  |  |  |  |  |  |
 1         |  x  |  |  |  |  |
 3         x  x  |  |  |  |  |
 2         x  |  x  |  |  |  |
 1         |  x  x  |  |  |  |
 4         x  x  x  |  |  |  |
 3         x  x  |  x  |  |  |
 5         x  x  x  x  |  |  |
 1         |  |  x  x  x  |  |
 2         x  |  x  x  x  |  |
 4         x  x  x  |  x  |  |
 6         x  x  x  x  x  |  |
 7         x  x  x  x  x  x  |
 1         |  x  |  x  |  x  x
 3         x  x  |  x  |  x  x
 5         x  x  x  x  |  x  x
 2         x  |  x  x  x  x  x
 8         x  x  x  x  x  x  x
 6         x  x  x  x  x  |  x
 1         |  x  x  |  x  x  x
 .
 .
 .
		

Crossrefs

Programs

  • Mathematica
    c[] := 0; q[] := 1; r = k = 1; nn = 120; Do[Set[{a[n], c[k]}, {k, n + k*q[k] + 1}]; q[k]++; If[k > r, r = k]; k = MinimalBy[Range[r], c, 1][[1]]; If[c[k] > n + 1, k = r + 1], {n, nn}]; Array[a, nn] (* Michael De Vlieger, Aug 13 2023 *)
  • PARI
    A364603(N) = {my(a=vector(N),z=1); for(s=1,N, if(a[s],next); my(m=0); for(i=s,N, if(!a[i], a[i]=z; i+=(z*(m++)))); z++); a}
    
  • Python
    def A364603(N):
        a = [0]*N; z=s=0
        while(s
    				

A372704 a(1)=1; a(2)=2; for n>1, this is the lexicographically earliest sequence such that, following each occurrence of a(n), a(n) is banned for the next k terms, where k is the number of terms prior to a(n) that are not equal to a(n).

Original entry on oeis.org

1, 2, 1, 2, 1, 3, 2, 1, 4, 5, 6, 2, 1, 3, 7, 8, 9, 4, 10, 5, 2, 1, 6, 11, 12, 13, 3, 14, 15, 7, 16, 8, 17, 9, 4, 18, 19, 2, 1, 5, 10, 20, 21, 22, 6, 23, 24, 11, 25, 12, 26, 3, 13, 27, 28, 14, 29, 15, 7, 30, 31, 16, 8, 32, 33, 17, 9, 4, 34, 35, 2, 1, 18, 19, 36
Offset: 1

Views

Author

Neal Gersh Tolunsky, May 10 2024

Keywords

Comments

1 occurs immediately after its ban ends so that the i-th occurrence of a(n) = 1, for i >= 2, is at n = 2^(i-2) + i = A052968(i-1).
2 occurs immediately after its ban ends, since it turns out that's immediately before the ban on 1 ends, so the i-th occurrence of a(n) = 2 is at n = 2^(i-1) + i = A005126(i-1).
If the definition is changed so that k is the number of terms in the sequence thus far equal to a(n) (rather than unequal), this becomes A002260 without the initial 1.

Examples

			  a(n)   ban 1  2  3  4  5  6 ...
   1         |  |  |  |  |  |
   2         |  |  |  |  |  |
   1         |  x  |  |  |  |
   2         x  |  |  |  |  |
   1         |  x  |  |  |  |
   3         x  x  |  |  |  |
   2         x  |  x  |  |  |
   1         |  x  x  |  |  |
   4         x  x  x  |  |  |
   5         x  x  x  x  |  |
   6         x  x  x  x  x  |
   2         x  |  |  x  x  x
   1         |  x  |  x  x  x
   3         x  x  x  x  x  x
		

Crossrefs

Programs

  • Python
    from collections import Counter
    from itertools import count, islice
    def agen(): # generator of terms
        an, ban, occurs = 1, {1: 1}, Counter([1])
        for n in count(2):
            yield an
            an = next(k for k in count(1) if k not in ban)
            for k in list(ban):
                if ban[k] > 1: ban[k] -= 1
                else: del ban[k]
            ban[an] = n - 1 - occurs[an]
            occurs[an] += 1
    print(list(islice(agen(), 75))) # Michael S. Branicky, May 10 2024

Extensions

a(20) and beyond from Michael S. Branicky, May 10 2024
Showing 1-2 of 2 results.