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
-
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 *)
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
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.
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
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)
- Rémy Sigrist, Table of n, a(n) for n = 1..25000
- Brady Haran and N. J. A. Sloane, "A Number Sequence with Everything" (the Inventory Sequence A342585), Numberphile video, November 2022.
- Hans Havermann, Colored plot of 1000467 terms [See Comments for a description of this plot]
- Hugo Pfoertner, Listening to the first 100000 terms of A342585, YouTube video from "Talabfahrer".
- Hugo Pfoertner, Hear 1 million terms of A342585, YouTube video from "Talabfahrer", alternative audio conversion.
- Luc Rousseau, AWK program for A342585
- Rémy Sigrist, Scatterplot of the first 10^6 terms
- Rémy Sigrist, Scatterplot of the first 10^7 terms
- Rémy Sigrist, Scatterplot of the first 10^8 terms
- Rémy Sigrist, Table of n, a(n) for n = 1..100000
- Rémy Sigrist, PARI program for A342585
- Jan Ritsema van Eck, Graph #1: 1000 terms (blue) and inverse triangular numbers A003056 (orange)
- Jan Ritsema van Eck, Graph #2: 10000 terms (blue) and inverse triangular numbers A003056 (orange)
- N. J. A. Sloane, "A Handbook of Integer Sequences" Fifty Years Later, arXiv:2301.03149 [math.NT], 2023, p. 21.
- Index entries for sequences related to the inventory sequence
-
# See Links section. - Luc Rousseau, May 02 2021
-
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
-
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
-
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 *)
-
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
-
\\ See Links section.
-
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
-
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
-
# 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
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;
-
Block[{a, c, j, k, m}, a[1] = c[] = 0; j = c[0] = 1; Do[k = 0; While[c[k] > 0, j++; Set[m, c[k]]; Set[a[j], m]; c[If[m < 1, 0, DigitCount[m, 2, 1] ] ]++; k++]; j++; Set[a[j], 0]; c[0]++, 25]; Array[a, j] ] (* _Michael De Vlieger, Jun 25 2025 *)
-
from collections import Counter
def w(n): return bin(n).count("1")
def aupton(nn):
num, alst, inventory = 0, [0], Counter([0])
for n in range(1, nn+1):
c = inventory[num]
num = 0 if c == 0 else num + 1
alst.append(c)
inventory.update([w(c)])
return alst
print(aupton(76)) # 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
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.
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
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.
-
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 *)
-
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
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
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.
-
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
a(10) = 3 because a(9) = 1 and 3 other 1s appear before that.
-
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
-
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
Showing 1-8 of 8 results.
Comments