login
Lengths of successive runs of primes in A090252.
3

%I #17 Jun 05 2022 11:44:22

%S 3,1,3,2,7,5,1,14,11,2,1,29,22,5,2,58,1,45,1,1,10,1,5,117,3,90,2,2,21,

%T 2,11,1,1,39,195,7,181,5,5,1,42,7,23,2,3,79,391,14,1,362,1,11,1,1,11,

%U 1,1,3,1,85,15,46,5,7,158,782,1,29,1,3,1,725,1,1,2,22,2,2,23,2,3,7,2,170,31,93,1,1,11,15,317,1,1089,475,2,58,1,1,3,7,2,1450

%N Lengths of successive runs of primes in A090252.

%H N. J. A. Sloane, <a href="/A354151/b354151.txt">Table of n, a(n) for n = 1..2148</a> [Based on Russ Cox's 5 million term data file for A090252]

%e A090252 begins 1, 2, 3, 5, 4, 7, 9, 11, 13, 17, 8, 19, 23, 25, 21, 29, 31, ... which, writing N for a nonprime and P for a prime, is NPPPNPNPPPNPPNPP... The runs of primes have lengths 3, 1, 3, 2, ...

%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, run = [1], {1}, 2, 0

%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): run += 1

%o elif run > 0: yield run; run = 0

%o while mink in aset: mink += 1

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

%Y Cf. A090252, A354148, A249033.

%K nonn

%O 1,1

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