login
The index of A358405 where n first appears, or 0 if n never appears.
3

%I #10 Nov 14 2022 09:59:39

%S 1,3,5,10,16,8,19,141,14,190,25,22,416,70,54,162,32,308,169,67,93,203,

%T 118,513,196,29,40,200,861,37,74,1081,82,216,208,363,90,46,375,1675,

%U 1091,333,1407,812,166,78,51,1099,115,193,1243,64,595,98,58,367,617,235,325,766,2137,272,124

%N The index of A358405 where n first appears, or 0 if n never appears.

%C See A358405 for further details.

%o (Python)

%o from itertools import count, islice

%o def agen():

%o k, an, first, prev = 0, 0, {0: 1}, {0: 1}

%o for n in count(2):

%o while k in first: yield first[k]; k += 1

%o an1 = 0 if first[an] == n-1 else max(n-1-prev[an], first[an])

%o if an1 not in first: first[an1] = prev[an1] = n

%o prev[an] = n-1

%o an = an1

%o print(list(islice(agen(), 63))) # _Michael S. Branicky_, Nov 14 2022

%Y Cf. A358405, A358402, A358403, A181391.

%K nonn

%O 0,2

%A _Scott R. Shannon_, Nov 14 2022