login
Index of prime(n) in A090252.
6

%I #10 May 27 2022 12:58:55

%S 2,3,4,6,8,9,10,12,13,16,17,18,19,20,21,22,24,25,26,27,28,30,33,34,35,

%T 36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,58,61,

%U 62,64,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,97,98,99,100

%N Index of prime(n) in A090252.

%C All the primes appear in A090252 and in their correct order.

%H N. J. A. Sloane, <a href="/A354148/b354148.txt">Table of n, a(n) for n = 1..9800</a>

%e A090252 begins 1, 2, 3, 5, 4, 7, 9, ..., so the indices of the primes are 2, 3, 4, 6, ...

%o (Python)

%o from math import gcd, prod

%o from sympy import isprime

%o from itertools import count, islice

%o def agen(): # generator of terms

%o alst, aset, mink = [1], {1}, 2

%o for n in count(2):

%o k, s = mink, n - n//2

%o prodall = prod(alst[n-n//2-1:n-1])

%o while k in aset or gcd(prodall, k) != 1: k += 1

%o alst.append(k); aset.add(k)

%o if isprime(k): yield n

%o while mink in aset: mink += 1

%o print(list(islice(agen(), 83))) # _Michael S. Branicky_, May 23 2022

%Y Cf. A090252, A354146.

%K nonn

%O 1,1

%A _N. J. A. Sloane_, May 22 2022