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.
%I A342585 #193 Dec 17 2023 11:21:58 %S A342585 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, %T A342585 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, %U A342585 2,0,10,11,8,6,11,6,9,3,2,5,3,2,0,11,11,10 %N 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. %C A342585 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. %C A342585 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 %C A342585 A similar situation occurs at n=124, where 14 has not yet appeared in the sequence, although 15 has appeared. %C A342585 Reminiscent of Van Eck's sequence A181391. - _N. J. A. Sloane_, May 02 2021 %C A342585 From _Jan Ritsema van Eck_, May 02 2021: (Start) %C A342585 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). %C A342585 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) %C A342585 Comment on the colored plot of the first 1000467 terms, from _Hans Havermann_, May 02 2021: (Start) %C A342585 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. %C A342585 Your browser will likely compress the very large image to window size, so click on it to expand. %C A342585 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. %C A342585 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. %C A342585 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) %C A342585 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 %C A342585 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 %C A342585 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 %H A342585 Rémy Sigrist, <a href="/A342585/b342585.txt">Table of n, a(n) for n = 1..25000</a> %H A342585 Brady Haran and N. J. A. Sloane, <a href="https://www.youtube.com/watch?v=rBU9E-ZOZAI">"A Number Sequence with Everything" (the Inventory Sequence A342585)</a>, Numberphile video, November 2022. %H A342585 Hans Havermann, <a href="/A342585/a342585_3.png">Colored plot of 1000467 terms</a> [See Comments for a description of this plot] %H A342585 Hugo Pfoertner, <a href="https://youtu.be/_AOGsnH3UCs">Listening to the first 100000 terms of A342585</a>, YouTube video from "Talabfahrer". %H A342585 Hugo Pfoertner, <a href="https://youtu.be/zsh3n52SS5E">Hear 1 million terms of A342585</a>, YouTube video from "Talabfahrer", alternative audio conversion. %H A342585 Luc Rousseau, <a href="/A342585/a342585.awk.txt">AWK program for A342585</a> %H A342585 Rémy Sigrist, <a href="/A342585/a342585.png">Scatterplot of the first 10^6 terms</a> %H A342585 Rémy Sigrist, <a href="/A342585/a342585_1.png">Scatterplot of the first 10^7 terms</a> %H A342585 Rémy Sigrist, <a href="/A342585/a342585_2.png">Scatterplot of the first 10^8 terms</a> %H A342585 Rémy Sigrist, <a href="/A342585/a342585.txt">Table of n, a(n) for n = 1..100000</a> %H A342585 Rémy Sigrist, <a href="/A342585/a342585.gp.txt">PARI program for A342585</a> %H A342585 Jan Ritsema van Eck, <a href="/A342585/a342585.pdf">Graph #1: 1000 terms (blue) and inverse triangular numbers A003056 (orange)</a> %H A342585 Jan Ritsema van Eck, <a href="/A342585/a342585_1.pdf">Graph #2: 10000 terms (blue) and inverse triangular numbers A003056 (orange)</a> %H A342585 N. J. A. Sloane, <a href="https://arxiv.org/abs/2301.03149">"A Handbook of Integer Sequences" Fifty Years Later</a>, arXiv:2301.03149 [math.NT], 2023, p. 21. %H A342585 <a href="/index/In#inventory">Index entries for sequences related to the inventory sequence</a> %e A342585 As an irregular triangle this begins: %e A342585 0; %e A342585 1, 1, 0; %e A342585 2, 2, 2, 0; %e A342585 3, 2, 4, 1, 1, 0; %e A342585 4, 4, 4, 1, 4, 0; %e A342585 5, 5, 4, 1, 6, 2, 1, 0; %e A342585 6, 7, 5, 1, 6, 3, 3, 1, 0; %e A342585 7, 9, 5, 3, 6, 4, 4, 2, 0; %e A342585 8, 9, 6, 4, 9, 4, 5, 2, 1, 3, 0; %e A342585 9, 10, 7, 5, 10, 6, 6, 3, 1, 4, 2, 0; %e A342585 10, 11, 8, 6, 11, 6, 9, 3, 2, 5, 3, 2, 0; %e A342585 ... %e A342585 For row lengths see A347299. - _N. J. A. Sloane_, Aug 27 2021 %e A342585 From _David James Sycamore_, Oct 18 2021: (Start) %e A342585 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. %e A342585 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. %e A342585 a(5) = 2 since the count is reset, a(1) = a(4) = 0 and a(0), a(3) respectively, precede them. (End) %p A342585 a:= proc(n) option remember; local t; %p A342585 t:= `if`(a(n-1)=0, 0, b(n-1)+1); %p A342585 b(n):=t; add(`if`(a(j)=t, 1, 0), j=1..n-1) %p A342585 end: b(1), a(1):= 0$2: %p A342585 seq(a(n), n=1..120); # _Alois P. Heinz_, Mar 16 2021 %t A342585 a[n_] := a[n] = Module[{t}, t = If[a[n-1] == 0, 0, b[n-1]+1]; %t A342585 b[n] = t; Sum[If[a[j] == t, 1, 0], {j, 1, n-1}]]; %t A342585 b[1] = 0; a[1] = 0; %t A342585 Array[a, 120] (* _Jean-François Alcover_, May 03 2021, after _Alois P. Heinz_ *) %o A342585 (Python) %o A342585 def calc(required_value_number): %o A342585 values_lst = [] %o A342585 current_count = 0 %o A342585 new_value = 0 %o A342585 for i in range(required_value_number): %o A342585 new_value = values_lst.count(current_count) %o A342585 values_lst.append(new_value) %o A342585 if new_value == 0: %o A342585 current_count = 0 %o A342585 else: %o A342585 current_count += 1 %o A342585 return new_value # Written by Gilad Moyal %o A342585 (Python) %o A342585 from collections import Counter %o A342585 def aupton(terms): %o A342585 num, alst, inventory = 0, [0], Counter([0]) %o A342585 for n in range(2, terms+1): %o A342585 c = inventory[num] %o A342585 num = 0 if c == 0 else num + 1; alst.append(c); inventory.update([c]) %o A342585 return alst %o A342585 print(aupton(84)) # _Michael S. Branicky_, Jun 12 2021 %o A342585 (PARI) %o A342585 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 %o A342585 (PARI) \\ See Links section. %o A342585 (AWK) # See Links section. - _Luc Rousseau_, May 02 2021 %o A342585 (MATLAB) %o A342585 function [val,arr]=invSeq(N) % val = Nth term, arr = whole array up to N %o A342585 k=0; %o A342585 arr=zeros(1,N); % pre-allocate array %o A342585 for i=1:N %o A342585 an=sum((k==arr(2:i))); %o A342585 arr(i)=an; %o A342585 if an == 0 %o A342585 k = 0; %o A342585 else %o A342585 k=k+1; %o A342585 end %o A342585 end %o A342585 val=arr(end); %o A342585 end % _Ben Cha_, Nov 11 2022 %o A342585 (R) %o A342585 # Prints the first 10,068 terms %o A342585 library("dplyr") %o A342585 options(max.print=11000) %o A342585 inventory <- data.frame(1, 0) %o A342585 colnames(inventory) <- c("n", "an") %o A342585 value_to_count = 0 %o A342585 n = 1 %o A342585 for(x in 1:128) # Increase the 128 for more terms. The number of terms %o A342585 # given is on the order of x^1.9 in the region around 128. %o A342585 { %o A342585 status <- TRUE %o A342585 while(status) %o A342585 { %o A342585 count <- length(which(inventory$an == value_to_count)) %o A342585 n = n + 1 %o A342585 inventory <- rbind(inventory, c(n, count)) %o A342585 status <- isTRUE(count != 0) %o A342585 value_to_count = value_to_count + 1 %o A342585 } %o A342585 value_to_count = 0 %o A342585 } %o A342585 inventory # _Damon Lay_, Nov 10 2023 %Y A342585 Records: A347305 and A348782. %Y A342585 Cf. A181391, A343878, A343880, A347299, A347315, A347316, A347317. %Y A342585 Other inventory-type sequences: A030717, A174382, A333867, A358066, A357443, A356784. %Y A342585 A012257 (cf. also A011784) reverses the inventory process. %Y A342585 See A347062, A347738, A355916, A355917, A355918, A357317 for variants. %K A342585 nonn,look,easy,nice %O A342585 1,5 %A A342585 _Joseph Rozhenko_, Mar 16 2021