A361172 a(n) is the smallest positive number not among the terms between a(n-1) and the previous most recent occurrence of a(n-1) inclusive; if a(n-1) is a first occurrence, set a(n)=1; a(1)=1.
1, 1, 2, 1, 3, 1, 2, 4, 1, 3, 5, 1, 2, 6, 1, 3, 4, 7, 1, 2, 5, 8, 1, 3, 6, 9, 1, 2, 4, 10, 1, 3, 5, 7, 11, 1, 2, 6, 8, 12, 1, 3, 4, 9, 13, 1, 2, 5, 10, 14, 1, 3, 6, 7, 15, 1, 2, 4, 8, 11, 16, 1, 3, 5, 9, 12, 17, 1, 2, 6, 10, 13, 18, 1, 3, 4, 7, 14, 19, 1, 2, 5, 8, 15, 20, 1
Offset: 1
Keywords
Examples
a(11)=5 because between a(10)=3 and the previous 3 (3, 1, 2, 4, 1, 3), the smallest missing number is 5, so a(11)=5.
Links
- Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
- Neal Gersh Tolunsky, Scatterplot of the first 13158 terms
Programs
-
PARI
{ pos = [0]; v = 1; for (n = 1, #a = vector(86), print1 (a[n] = v", "); v = 1; if (a[n] <= #pos && pos[a[n]], r = Set(a[pos[a[n]]..n]); while (setsearch(r, v), v++)); while (#pos < a[n], pos = concat(pos, vector(#pos));); pos[a[n]] = n;); } \\ Rémy Sigrist, Mar 04 2023
Comments