[go: up one dir, main page]

login
Search: a355917 -id:a355917
     Sort: relevance | references | number | modified | created      Format: long | short | data
Highest index in n-th inventory in A355916 and A355917.
+20
4
0, 1, 3, 5, 7, 11, 13, 16, 17, 19, 22, 23, 26, 27, 29, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 56, 59, 62, 64, 66, 67, 71, 72, 73, 74, 75, 78, 81, 82, 84, 85, 88, 89, 91, 93, 95, 97, 99, 102, 103, 106, 108, 109, 111, 113, 115, 117, 119, 121, 123, 125
OFFSET
1,3
LINKS
Rémy Sigrist, C program
PROG
(C) See Links section.
(Python)
from collections import Counter
from itertools import count, islice
def agen():
num, inventory = 0, Counter([0, 0])
yield 0
for k in count(2):
c = [inventory[num], num]
if c[0] == 0: yield num; num = 0
else: num = num + 1
inventory.update(c)
print(list(islice(agen(), 63))) # Michael S. Branicky, Sep 25 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Sep 24 2022
EXTENSIONS
More terms from Rémy Sigrist, Sep 25 2022
STATUS
approved
Positions of 0's in A355917.
+20
2
1, 3, 7, 13, 21, 33, 47, 64, 82, 102, 125, 149, 176, 204, 234, 267, 302, 339, 378, 419, 462, 507, 554, 603, 654, 707, 763, 820, 880, 943, 1008, 1075, 1143, 1215, 1288, 1362, 1437, 1513, 1592, 1674, 1757, 1842, 1928, 2017, 2107, 2199, 2293, 2389, 2487, 2587, 2690
OFFSET
1,2
COMMENTS
A355916(2*a(n)-1) = 0.
LINKS
MATHEMATICA
nn = 51; c[_] = 0; i = 1; Reap[Do[k = 0; While[c[k] > 0, Set[m, c[k]]; c[m]++; c[k]++; i += 2; k++]; Set[m, c[k]]; c[m]++; c[k]++; Sow[(i + 1)/2]; i += 2, {n, nn}] ][[-1, -1]]
PROG
(Python)
from itertools import count, islice
from collections import Counter
def agen():
yield 1
num, alst, inventory = 0, [0, 0], Counter([0, 0])
for n in count(2):
c = [inventory[num], num]
num = 0 if c[0] == 0 else num + 1
if c[0] == 0: yield n
inventory.update(c)
print(list(islice(agen(), 51))) # Michael S. Branicky, Oct 05 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Michael De Vlieger, Sep 25 2022
STATUS
approved
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.
+10
59
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,5
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
LINKS
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.
N. J. A. Sloane, "A Handbook of Integer Sequences" Fifty Years Later, arXiv:2301.03149 [math.NT], 2023, p. 21.
EXAMPLE
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)
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 *)
PROG
(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
(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.
(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
(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
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.
KEYWORD
nonn,look,easy,nice
AUTHOR
Joseph Rozhenko, Mar 16 2021
STATUS
approved
Variant of Inventory Sequence A342585 where indices are also counted (long version).
+10
6
0, 0, 2, 0, 0, 1, 4, 0, 1, 1, 1, 2, 0, 3, 6, 0, 4, 1, 2, 2, 1, 3, 2, 4, 0, 5, 8, 0, 6, 1, 5, 2, 2, 3, 3, 4, 2, 5, 2, 6, 0, 7, 10, 0, 7, 1, 9, 2, 4, 3, 5, 4, 4, 5, 3, 6, 2, 7, 1, 8, 1, 9, 1, 10, 0, 11, 12, 0, 11, 1, 11, 2, 6, 3, 7, 4, 5, 5, 5, 6, 4, 7, 2, 8, 2, 9, 2, 10, 3, 11, 1, 12, 0, 13, 14, 0, 13, 1, 15, 2, 8, 3, 9, 4, 8, 5, 6, 6, 5, 7, 5, 8, 4, 9, 3, 10, 4, 11, 2, 12, 2, 13, 1, 14, 1, 15, 0, 16
OFFSET
1,3
COMMENTS
Similar to A342585, except that when we take inventory, we write down what we are counting as a subscript on the count. So if we have found k copies of m so far, we write down k_m, and include both the k and m values when we next take inventory.
More than the usual number of terms are shown, in order to match A355917.
LINKS
Rémy Sigrist, PARI program
N. J. A. Sloane, The first eight inventories, with better alignment.
EXAMPLE
Initially we have no 0's, so the first inventory is 0_0. Just as in A342585, when we reach a count of zero, we take a new inventory.
Now we see two 0's, so we write down 2_0, followed by 0_1, since there are no 1's.
So the first two inventories are
0_0,
2_0, 0_1.
Now we see four 0's, so the next inventory starts 4_0, then 1_1, 1_2, and 0_3:
4_0, 1_1, 1_2, 0_3.
The first eight inventories are:
0_0,
2_0, 0_1,
4_0, 1_1, 1_2, 0_3,
6_0, 4_1, 2_2, 1_3, 2_4, 0_5,
8_0, 6_1, 5_2, 2_3, 3_4, 2_5, 2_6, 0_7,
10_0, 7_1, 9_2, 4_3, 5_4, 4_5, 3_6, 2_7, 1_8, 1_9, 1_10, 0_11,
12_0, 11_1, 11_2, 6_3, 7_4, 5_5, 5_6, 4_7, 2_8, 2_9, 2_10, 3_11, 1_12, 0_13,
14_0, 13_1, 15_2, 8_3, 9_4, 8_5, 6_6, 5_7, 5_8, 4_9, 3_10, 4_11, 2_12, 2_13, 1_14, 1_15, 0_16,
...
The sequence is obtained by reading the inventories, with each count followed by its index: 0, 0, 2, 0, 0, 1, 4, 0, 1, 1, 1, 2, 0, 3, ...
If the indices are omitted, we get the short version, A355917. A355918 lists the highest index in each inventory.
MATHEMATICA
nn = 9; c[_] = 0; a[1] = a[2] = 0; c[0] = 2; i = 3; Do[k = 0; While[c[k] > 0, Set[{a[i], a[i + 1]}, {c[k], k}]; c[a[i]]++; c[a[i + 1]]++; i += 2; k++]; Set[{a[i], a[i + 1]}, {c[k], k}]; c[a[i]]++; c[a[i + 1]]++; i += 2, {n, 2, nn}]; Array[a, i - 1] (* Michael De Vlieger, Sep 25 2022 *)
PROG
(PARI) See Links section.
(Python)
from collections import Counter
def aupton(terms):
num, alst, inventory = 0, [0, 0], Counter([0, 0])
for n in range(3, 3+terms//2):
c = [inventory[num], num]
num = 0 if c[0] == 0 else num + 1
alst.extend(c)
inventory.update(c)
return alst[:terms]
print(aupton(128)) # Michael S. Branicky, Sep 25 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
N. J. A. Sloane, Sep 24 2022
STATUS
approved
a(1) = 1, thereafter, first differences of A357370.
+10
2
1, 2, 4, 6, 8, 12, 14, 17, 18, 20, 23, 24, 27, 28, 30, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 56, 57, 60, 63, 65, 67, 68, 72, 73, 74, 75, 76, 79, 82, 83, 85, 86, 89, 90, 92, 94, 96, 98, 100, 103, 104, 107, 109, 110, 112, 114, 116, 118, 120, 122, 124, 126
OFFSET
1,2
COMMENTS
Length of row n of A355917 taken as an irregular triangle where the rows terminate in 0.
Length of inventory n in A355916 = 2*a(n).
Final subscript in the n-th inventory in A355916 = a(n) - 1.
LINKS
MATHEMATICA
nn = 63; c[_] = 0; i = 1; {1}~Join~Differences@ Reap[Do[k = 0; While[c[k] > 0, Set[m, c[k]]; c[m]++; c[k]++; i += 2; k++]; Set[m, c[k]]; c[m]++; c[k]++; Sow[(i + 1)/2]; i += 2, {n, nn}]][[-1, -1]]
CROSSREFS
KEYWORD
nonn
AUTHOR
Michael De Vlieger, Sep 25 2022
STATUS
approved

Search completed in 0.010 seconds