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.

A347318 Length of row n in A347317.

Original entry on oeis.org

1, 3, 4, 6, 6, 8, 9, 11, 12, 13, 15, 17, 19, 23, 29, 36, 43, 60, 91, 150, 265, 493, 946, 1848, 3649, 7246, 14437, 28814, 57564, 115059, 230044, 460010, 919938, 1839789, 3679485, 7358874, 14717646, 29435186, 58870261, 117740405, 235480687, 470961245, 941922354, 1883844567
Offset: 0

Views

Author

N. J. A. Sloane, Sep 10 2021

Keywords

Crossrefs

Programs

  • Mathematica
    Block[{c, k, m, r = 0}, c[0] = 1; Prepend[Differences[#], First[#]] &@ Position[{-1}~Join~Reap[Do[k = 0; While[k <= r, If[IntegerQ@ c[k], Set[m, c[k]], Set[c[k], 0]; Set[m, 0]]; If[m > r, r = m]; Sow[m]; If[IntegerQ@ c[m], c[m]++, c[m] = 1]; k++]; Sow[-1]; c[0]++, 32]][[-1, -1]], -1][[All, 1]]] (* Michael De Vlieger, Oct 12 2021 *)

Extensions

a(10)-a(43) from Andrey Zabolotskiy, Sep 10 2021

A347327 Initial term in row n when A347317 is written as an irregular triangle.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 6, 7, 9, 11, 13, 15, 17, 19, 22, 29, 41, 58, 89, 148, 263, 491, 944, 1846, 3647, 7244, 14435, 28812, 57562, 115057, 230042, 460008, 919936, 1839787, 3679483, 7358872, 14717644, 29435184, 58870259, 117740403, 235480685, 470961243, 941922352, 1883844565, 3767688985, 7535377819
Offset: 0

Views

Author

N. J. A. Sloane, Sep 14 2021

Keywords

Examples

			The first few rows of A347317 are
   0;
   1,  1,  0;
   2,  2,  2,  0;
   3,  2,  4,  1,  1,  0;
   4,  4,  4,  1,  4,  0;
   5,  5,  4,  1,  6,  2,  1,  0;
...
and the initial terms are 0, 1, 2, 3, 4, 5, ...  Note however (see A347318) that after a while this sequence increases at least exponentially.
		

Crossrefs

Extensions

Terms a(20) and beyond from Andrey Zabolotskiy, Sep 14 2021

A342585 Inventory sequence: record the number of zeros thus far in the sequence, then the number of ones thus far, then the number of twos thus far and so on, until a zero is recorded; the inventory then starts again, recording the number of zeros.

Original entry on oeis.org

0, 1, 1, 0, 2, 2, 2, 0, 3, 2, 4, 1, 1, 0, 4, 4, 4, 1, 4, 0, 5, 5, 4, 1, 6, 2, 1, 0, 6, 7, 5, 1, 6, 3, 3, 1, 0, 7, 9, 5, 3, 6, 4, 4, 2, 0, 8, 9, 6, 4, 9, 4, 5, 2, 1, 3, 0, 9, 10, 7, 5, 10, 6, 6, 3, 1, 4, 2, 0, 10, 11, 8, 6, 11, 6, 9, 3, 2, 5, 3, 2, 0, 11, 11, 10
Offset: 1

Views

Author

Joseph Rozhenko, Mar 16 2021

Keywords

Comments

To get started we ask: how many zero terms are there? Since there are no terms in the sequence yet, we record a '0', and having recorded a '0', we begin again: How many zero terms are there? There is now one 0, so we record a '1' and continue. How many 1's are there? There's currently one '1' in the sequence, so we record a '1' and continue. How many 2's are there? There are no 2's yet, so we record a '0', and having recorded a 0, we begin again with the question "how many zero terms are there?" And so on.
a(46) = 0 because no 8's appear before it; but note a higher number, namely 9, has appeared. - Michael S. Branicky, Mar 16 2021
A similar situation occurs at n=124, where 14 has not yet appeared in the sequence, although 15 has appeared.
Reminiscent of Van Eck's sequence A181391. - N. J. A. Sloane, May 02 2021
From Jan Ritsema van Eck, May 02 2021: (Start)
The first 1000 terms seem to grow more or less in saw-tooth fashion with the largest terms (= the number of 0's), as well as the distance between the 0's, both approximately equal to the inverse triangular numbers A003056 (see attached graph #1).
But the picture changes when we go out to 10000 terms. Around the 1700th term, the 1's become more frequent than the 0's and the largest values are consistently somewhat larger than the inverse triangular numbers. Around the 2500th term the 2's become the most frequent number. Also after some 4000 terms, the largest values become much larger than the inverse triangular numbers. See graph #2. (End)
Comment on the colored plot of the first 1000467 terms, from Hans Havermann, May 02 2021: (Start)
If one is drawing a points-joined graph, it will obscure some of the inherent large-number dynamics. To get around that, this plot joins the points with a green line, superimposing the actual points in blue. This plot was created by Mathematica.
Your browser will likely compress the very large image to window size, so click on it to expand.
The points fall into linear features of the various counts of the various integers. The count for each integer changes as we move towards infinity and hence crosses over (changes place with) other counts unpredictably.
I decided to chart (see the blue text) the twenty largest counts at the rightmost spike which runs from the zero at 997010 to the zero at 1000467. These largest values are for the counts of integers 2 to 21 and appear at a(997013) for the 2-count; a(997014) for the 3-count, ..., and a(997032) for the 21-count.
The counts are 15275, 26832, 40162, 48539, 56364, 54372, 53393, 43588, 37288, 27396, 22425, 16735, 13099, 11460, 9466, 8386, 7191, 6478, 5777, and 5208, respectively. In my text they are sorted largest-to-smallest and written "count @ integer-being-counted": 56364 @ 6, 54372 @ 7, 53393 @ 8, 48539 @ 5, ... 5208 @ 21. (End)
A useful view may be gained by plotting the sequence against itself with an offset. Using the "Plot 2" link in the web page footer, enter "A342585" as sequences 1 and 2. Select "Plot Seq2(n+shift) vs Seq1(n)" and "Draw line segments". Start with "1" as the shift. The sequence appears somewhat like a fan, the first 4 or 5 sectors showing clearly, later sectors overlying each other. Larger shift values effectively compress early sectors into the vertical axis, making later sectors more visible. - Peter Munn, May 08 2021
For a version where a row ends not at the first zero, but rather at the last zero, see A347317. - N. J. A. Sloane, Sep 10 2021
For n around 2.5*10^9, the upper envelope of the sequence seems to be growing roughly like n/50, or maybe like O(n/log(n)). - N. J. A. Sloane, Feb 10 2023

Examples

			As an irregular triangle this begins:
   0;
   1,  1,  0;
   2,  2,  2,  0;
   3,  2,  4,  1,  1,  0;
   4,  4,  4,  1,  4,  0;
   5,  5,  4,  1,  6,  2,  1,  0;
   6,  7,  5,  1,  6,  3,  3,  1,  0;
   7,  9,  5,  3,  6,  4,  4,  2,  0;
   8,  9,  6,  4,  9,  4,  5,  2,  1,  3,  0;
   9, 10,  7,  5, 10,  6,  6,  3,  1,  4,  2,  0;
  10, 11,  8,  6, 11,  6,  9,  3,  2,  5,  3,  2,  0;
  ...
For row lengths see A347299. - _N. J. A. Sloane_, Aug 27 2021
From _David James Sycamore_, Oct 18 2021: (Start)
a(1) is 0 because the count is reset, and as yet there is no zero term immediately following another term. a(2) = 1 since the count is reset, a(1) = 0 and a(0) precedes it. The count now increments to terms equal to 1.
a(3) = 1 since a(2) = 1 and a(1) precedes it. a(4) = 0 because there is no term equal to 2 which is immediately preceded by another term.
a(5) = 2 since the count is reset, a(1) = a(4) = 0 and a(0), a(3) respectively, precede them. (End)
		

Crossrefs

Records: A347305 and A348782.
Other inventory-type sequences: A030717, A174382, A333867, A358066, A357443, A356784.
A012257 (cf. also A011784) reverses the inventory process.
See A347062, A347738, A355916, A355917, A355918, A357317 for variants.

Programs

  • AWK
    # See Links section. - Luc Rousseau, May 02 2021
    
  • MATLAB
    function [val,arr]=invSeq(N) % val = Nth term, arr = whole array up to N
    k=0;
    arr=zeros(1,N); % pre-allocate array
    for i=1:N
        an=sum((k==arr(2:i)));
        arr(i)=an;
        if an == 0
            k = 0;
        else
            k=k+1;
        end
    end
    val=arr(end);
    end % Ben Cha, Nov 11 2022
    
  • Maple
    a:= proc(n) option remember; local t;
          t:= `if`(a(n-1)=0, 0, b(n-1)+1);
          b(n):=t; add(`if`(a(j)=t, 1, 0), j=1..n-1)
        end: b(1), a(1):= 0$2:
    seq(a(n), n=1..120);  # Alois P. Heinz, Mar 16 2021
  • Mathematica
    a[n_] := a[n] = Module[{t}, t = If[a[n-1] == 0, 0, b[n-1]+1];
         b[n] = t; Sum[If[a[j] == t, 1, 0], {j, 1, n-1}]];
    b[1] = 0; a[1] = 0;
    Array[a, 120] (* Jean-François Alcover, May 03 2021, after Alois P. Heinz *)
  • PARI
    A342585_vec(N,c=[],i)=vector(N,j, while(#c<=i||#c<=c[i+1], c=concat(c,0)); c[i+=1]+if(c[1+c[i]]++&&!c[i]||j==1,i=0)) \\ M. F. Hasler, Nov 13 2021
    
  • PARI
    \\ See Links section.
    
  • Python
    def calc(required_value_number):
        values_lst = []
        current_count = 0
        new_value = 0
        for i in range(required_value_number):
            new_value = values_lst.count(current_count)
            values_lst.append(new_value)
            if new_value == 0:
                current_count = 0
            else:
                current_count += 1
        return new_value # Written by Gilad Moyal
    
  • Python
    from collections import Counter
    def aupton(terms):
      num, alst, inventory = 0, [0], Counter([0])
      for n in range(2, terms+1):
        c = inventory[num]
        num = 0 if c == 0 else num + 1; alst.append(c); inventory.update([c])
      return alst
    print(aupton(84)) # Michael S. Branicky, Jun 12 2021
    
  • R
    # Prints the first 10,068 terms
    library("dplyr")
    options(max.print=11000)
    inventory <- data.frame(1, 0)
    colnames(inventory) <- c("n", "an")
    value_to_count = 0
    n = 1
    for(x in 1:128) # Increase the 128 for more terms. The number of terms
                    # given is on the order of x^1.9 in the region around 128.
      {
      status <- TRUE
      while(status)
        {
        count <- length(which(inventory$an == value_to_count))
        n = n + 1
        inventory <- rbind(inventory, c(n, count))
        status <- isTRUE(count != 0)
        value_to_count = value_to_count + 1
        }
      value_to_count = 0
      }
    inventory # Damon Lay, Nov 10 2023

A352799 Inventory sequence of binary weights.

Original entry on oeis.org

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

Views

Author

David James Sycamore, Apr 03 2022

Keywords

Comments

Record the number of terms with binary weight zero, then successively record those with weights 1,2,... (including in the count the weights of new terms as they are recorded), until reaching a weight w for which there are zero terms with that weight, whereupon record a zero term. Repeat.

Examples

			a(0) = 0 because at the start there are no terms, therefore zero terms with binary weight zero.
a(1) = 1 because the first term (0) has binary weight zero and there is just one such term.
a(2) = 1 since a(1) = 1 has weight 1, and there is only one term with this weight.
a(3) = 0 since there are no terms with weight 2. Reset the count to zero weight and repeat.
a(4) = 2 because now there are 2 terms (a(0), a(3)) which have weight 0. And so on.
As an irregular triangle the sequence begins:
  0;
  1,  1, 0;
  2,  3, 1, 0;
  3,  4, 2, 0;
  4,  7, 2, 1, 0;
  5,  9, 4, 1, 0;
  6, 11, 5, 2, 0;
		

Crossrefs

Programs

Extensions

a(45) and beyond from Michael S. Branicky, Apr 03 2022

A347794 The "Look and Say" version of the Inventory sequence A342585.

Original entry on oeis.org

0, 1, 0, 1, 1, 0, 2, 3, 0, 3, 1, 1, 2, 2, 3, 0, 4, 5, 0, 5, 1, 3, 2, 4, 3, 2, 4, 2, 5, 0, 6, 7, 0, 6, 1, 6, 2, 5, 3, 3, 4, 4, 5, 3, 6, 1, 7, 0, 8, 9, 0, 8, 1, 7, 2, 8, 3, 5, 4, 6, 5, 5, 6, 3, 7, 3, 8, 1, 9, 0, 10, 11, 0, 10, 1, 8, 2, 11, 3, 6, 4, 8, 5, 7, 6, 5, 7, 6, 8, 2, 9, 2, 10, 2, 11, 0, 12
Offset: 0

Views

Author

Scott R. Shannon, Sep 13 2021

Keywords

Comments

This sequences uses the same rules as the Inventory sequence A342585 except here each term is described using the "Look and Say" method of A005150. See the Examples below. Start with a(0) = 0.

Examples

			a(1) = 1 and a(2) = 0, as after a(0) there is "one 0".
a(3) = 1 and a(4) = 1, as after a(0)..a(2) there is "one 1".
a(5) = 0 and a(6) = 2, as after a(0)..a(4) there are "zero 2's". As a number with zero occurrences has appeared, the count resets back to counting zeros.
a(7) = 3 and a(8) = 0, as after a(0)..a(6) there are "three 0's".
a(9) = 3 and a(10) = 1 as after a(0)..a(8) there are "three 1's".
a(11) = 1 and a(12) = 2 as after a(0)..a(10) there is "one 2".
a(13) = 2 and a(14) = 3 as after a(0)..a(12) there are "two 3's".
a(15) = 0 and a(16) = 4 as after a(0)..a(14) there are "zero 4's". As a number with zero occurrences has appeared, the count resets back to counting zeros.
		

Crossrefs

A361287 A variant of the inventory sequence A342585: now a row ends when the number of occurrences of the largest term in the sequence thus far has been recorded.

Original entry on oeis.org

0, 1, 1, 1, 3, 0, 1, 2, 4, 1, 1, 1, 2, 7, 2, 1, 1, 0, 0, 1, 4, 10, 3, 2, 2, 0, 0, 1, 0, 0, 1, 8, 12, 5, 2, 2, 1, 0, 1, 1, 0, 1, 0, 1, 11, 17, 7, 2, 2, 1, 0, 2, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 17, 23, 10, 2, 2, 1, 0, 2, 1, 0, 2, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0
Offset: 0

Views

Author

Robert Dober, Mar 07 2023

Keywords

Examples

			The triangle begins:
  0;
  1, 1;
  1, 3, 0, 1;
  2, 4, 1, 1, 1;
  2, 7, 2, 1, 1, 0, 0, 1;
  4, 10, 3, 2, 2, 0, 0, 1, 0, 0, 1;
  8, 12, 5, 2, 2, 1, 0, 1, 1, 0, 1, 0, 1;
 11, 17, 7, 2, 2, 1, 0, 2, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1;
 17, 23, 10, 2, 2, 1, 0, 2, 1, 0, 2, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1;
...
a(0)=0 because we begin each row by recording the number of zeros in the sequence. As yet, there are none. 0 is still the largest term in the sequence, so we begin the next row.
a(1)=1 because there is one 0. a(2)=1 because there is one 1. 1 is the largest term thus far, so we begin the next row.
a(3)=1 (there is still one zero); a(4)=3 (there are three 1s); a(5)=0 (no 2s); the row ends with a(6)=1 because there is one 3 and three is the largest term thus far.
		

Crossrefs

Programs

  • Mathematica
    len = 84; K = {0}; While[Length@K <= len, i = 0; While[i <= Max@K, AppendTo[K, Count[K, i]]; i++]]; Print[Take[K, len + 1]] (* Samuel Harkness, Mar 12 2023 *)
  • Python
    from collections import Counter
    from itertools import count, islice
    def agen(): # generator of terms
        an, b, m, inventory = 0, 0, 0, Counter([0])
        for n in count(1):
            yield an
            an = inventory[b]
            m = max(m, an)
            b = b + 1 if m > b else 0; inventory.update([an])
    print(list(islice(agen(), 85))) # Michael S. Branicky, Mar 07 2023

Formula

a(n) is the number of all a(k) == b(n) 0 <= k < n and b(0) = 0 and b(n) = b(n-1)+1 if an a(k) > b(n) exists for 0 <= k < n, and 0 otherwise.

Extensions

More terms from Alois P. Heinz, Mar 07 2023

A376076 A variant of the inventory sequence which only counts prime numbers and only allows the values in the sequence to be 0, 1, or a prime number.

Original entry on oeis.org

2, 2, 2, 3, 1, 3, 2, 3, 3, 3, 5, 1, 3, 5, 2, 5, 5, 3, 5, 7, 5, 1, 5, 7, 7, 3, 5, 7, 7, 5, 5, 7, 7, 7, 5, 7, 11, 7, 1, 5, 7, 11, 11, 3, 5, 7, 13, 11, 3, 1, 5, 7, 13, 13, 3, 3, 5, 11, 13, 13, 5, 5, 5, 11, 17, 13, 5, 5, 1, 5, 11, 19, 13, 7, 7, 1, 1, 5, 11, 19, 13, 7, 7, 1, 2, 5, 11, 23, 17, 7, 7, 2, 2, 1
Offset: 1

Views

Author

Anthony B Lara, Sep 08 2024

Keywords

Comments

The sequence starts with the seed [2, 2].
Construction is similar to A347317 except using only prime numbers. Each row ends after counting the highest prime that has occurred in the sequence so far.
When the number of 2's, 3's, 5's, p's is not a prime number, the sequence outputs the prime number closest to but less than the actual count. See example below.
Allowing 0 and 1 in the series is necessary as some primes enter the series before earlier primes. For example, generate the sequence using the example provided below and note on row 47 where 61 appears before 59 in the sequence, approximately the 391st element of the sequence. The effect becomes very clear after generating about 110 rows of data and only gets greater from there, given the overall tendency for increasing gaps between prime numbers.
Related sequences could be generated using different seed strings. Interestingly starting with the seed [3, 3] produces an irregular triangle of similar shape to [2, 2]. This does not seem to occur with 5, 5.
Testing further pairs of primes [p,p] as seeds reveals a subsequence of primes 11,17,29,41,59,71,101,107... that all form a similarly shaped irregular triangle after a trivial amount of 'count up' rows. This can be seen by comparing the row lengths of each pair of primes seed.
It appears that when any of these subsequence values are used as a pair of primes seed that sequence will never include any of the subsequence values. For example, using seed [11,11] the count of 2's skips values 11,17,29,41,59,71,101,107... The same is true if the seed [17,17], or any of the other subsequence values, are used.

Examples

			The sequence can be thought of as a row by row counting of prime occurrences with each column relating to a specific prime number, given the first two seed rows of 2 and 2.
As an irregular triangle this begins:
  Row1: 2 (seed)
  Row2: 2 (seed)
  Row3: 2
  Row4: 3 1
  Row5: 3 2
  Row6: 3 3
  Row7: 3 5 1
  Row8: 3 5 2
  Row9: 5 5 3
Note in Row8 how the number of 3's that have occurred so far is actually 6, but the rules of the sequence dictate outputting the nearest prime less than the count which is 5.
		

Crossrefs

Cf. A347317.

Programs

  • Python
    from itertools import islice
    from collections import Counter
    from sympy import isprime, nextprime, prevprime
    def agen(verbose=False): # generator of terms; verbose=True prints rows
        seed, bigp = [2, 2], 2
        c = Counter(seed)
        yield from seed
        if verbose: [print(k, end=",\n") for k in seed]
        while True:
            p = 2
            while p <= bigp:
                cp = c[p]
                if cp > 2 and not isprime(cp): cp = prevprime(cp)
                if cp > bigp: bigp = cp
                yield cp
                if verbose: print(cp, end=", ")
                c[cp] += 1
                p = nextprime(p)
            if verbose: print()
    print(list(islice(agen(), 94))) # Michael S. Branicky, Sep 10 2024

A354856 a(1) = 1, a(n) = the number of times a(n-1) appears among the first n-2 terms.

Original entry on oeis.org

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

Views

Author

Eric Fox, Jun 09 2022

Keywords

Examples

			a(10) = 3 because a(9) = 1 and 3 other 1s appear before that.
		

Crossrefs

Programs

  • PARI
    lista(nn) = my(va=vector(nn)); va[1] = 1; for (n=2, nn, my(vb = vector(n-2, k, va[k])); va[n] = #select(x->(x==va[n-1]), vb);); va; \\ Michel Marcus, Jun 13 2022
  • Python
    from collections import Counter
    from itertools import count, islice
    def agen(): # generator of terms
        anprev, an, inventory = None, 1, Counter()
        for n in count(2):
            yield an
            anprev, an = an, inventory[an]
            inventory[anprev] += 1
    print(list(islice(agen(), 80))) # Michael S. Branicky, Jun 09 2022
    

Formula

a(4n+1..4n+4) = 1, n+1, 0, n+1 for n >= 1. - Michael S. Branicky, Jun 12 2022

Extensions

a(54) and beyond from Michael S. Branicky, Jun 12 2022
Showing 1-8 of 8 results.