login
a(n) is the smallest positive number not among the terms between a(n-1) and the most recent previous term whose value appears with the same frequency (inclusive); if no such term exists, set a(n)=1; a(1)=1.
1

%I #22 May 13 2023 23:50:31

%S 1,1,2,1,3,4,1,2,5,3,1,4,2,6,7,1,3,4,1,2,5,8,6,1,3,4,1,2,7,5,9,10,1,3,

%T 4,1,2,6,7,1,3,4,1,2,5,8,11,9,1,3,4,1,2,6,7,1,3,4,1,2,5,10,8,12,13,1,

%U 3,4,1,2,6,7,1,3,4,1,2,5,9,10,1,3,4,1,2,6

%N a(n) is the smallest positive number not among the terms between a(n-1) and the most recent previous term whose value appears with the same frequency (inclusive); if no such term exists, set a(n)=1; a(1)=1.

%C From _Samuel Harkness_, Mar 11 2023: (Start)

%C Observations:

%C Record values k > 2 seem to occur at the following places:

%C First k for k == 0 (mod 3) occurs at n = 2^(k/3+2) + k/3 - 4;

%C First k for k == 1 (mod 3) occurs at n = 2^((k-1)/3+2) + (k-1)/3 - 3;

%C First k for k == 2 (mod 3) occurs at n = 3*(2^((k+1)/3)) + (k-14)/3.

%C For any value k, frequency(k) ~= 2*frequency(3+k). For any value j >= 0, frequency(2+j) ~= frequency(3+j) ~= frequency(4+j).

%C This sequence contains many recurring strings. For example, {1, 3, 4, 1, 2} occurs 12499 times in the first 100000 terms. From its 5th occurrence at a(40) through its 64th occurrence at a(517), the number of terms between each {1, 3, 4, 1, 2} minus one gives

%C {1 3 1 4 ...}

%C First 1 term of A001511, 3, first 1 term of A001511, 4.

%C {... 1 2 1 4 1 2 1 5 ...}

%C First 3 terms of A001511, 4, first 3 terms of A001511, 5.

%C {... 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 6 ...

%C First 7 terms of A001511, 5, first 7 terms of A001511, 6.

%C {... 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 ...}

%C First 15 terms of A001511, 6, first 15 terms of A001511, 7.

%C (End)

%H Samuel Harkness, <a href="/A361429/b361429.txt">Table of n, a(n) for n = 1..10000</a>

%H Samuel Harkness, <a href="/A361429/a361429.m.txt">MATLAB program</a>

%e a(6)=4 because in the sequence so far (1, 1, 2, 1, 3), the most recent term with the same number of occurrences as a(5)=3 is a(3)=2. Between a(3) and a(5), (2, 1, 3), the smallest missing number is 4, so a(6)=4.

%e a(8)=2 because between a(7)=1 and the previous value with the same frequency count a(4)=1 (1, 3, 4, 1), the smallest missing number is 2, so a(8)=2.

%o (MATLAB) See Links section.

%Y Cf. A361172, A358921, A001511.

%K nonn

%O 1,3

%A _Neal Gersh Tolunsky_, Mar 11 2023