cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A354151 Lengths of successive runs of primes in A090252.

This page as a plain text file.
%I A354151 #17 Jun 05 2022 11:44:22
%S A354151 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 A354151 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 A354151 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 A354151 Lengths of successive runs of primes in A090252.
%H A354151 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 A354151 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 A354151 (Python)
%o A354151 from math import gcd, prod
%o A354151 from sympy import isprime
%o A354151 from itertools import count, islice
%o A354151 def agen(): # generator of terms
%o A354151     alst, aset, mink, run = [1], {1}, 2, 0
%o A354151     for n in count(2):
%o A354151         k, s = mink, n - n//2
%o A354151         prodall = prod(alst[n-n//2-1:n-1])
%o A354151         while k in aset or gcd(prodall, k) != 1: k += 1
%o A354151         alst.append(k); aset.add(k)
%o A354151         if isprime(k): run += 1
%o A354151         elif run > 0: yield run; run = 0
%o A354151         while mink in aset: mink += 1
%o A354151 print(list(islice(agen(), 45))) # _Michael S. Branicky_, May 28 2022
%Y A354151 Cf. A090252, A354148, A249033.
%K A354151 nonn
%O A354151 1,1
%A A354151 _N. J. A. Sloane_, May 27 2022