login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Indices n where a run of primes begins in A376198.
10

%I #19 Oct 07 2024 14:17:37

%S 2,9,23,52,110,231,472,965,1958,3962,7980,16029,32181,64597,129574,

%T 259798,520835,1043833,2091473,4190135,8392863,16809322,33661860,

%U 67402676,134952624,270177158,540861852,1082667610,2167106199,4337519113,8681255531,17374202846,34770433922,69582458821,139243546013,278635987083

%N Indices n where a run of primes begins in A376198.

%o (Python)

%o from itertools import count, islice

%o from sympy import isprime, nextprime

%o def A376750_4gen(): # generator of terms for A376750..4

%o an, smc, smp = 2, 4, 3,

%o wasprime = startp = startn = endp = endn = rl = 0

%o for n in count(2):

%o if not isprime(an):

%o if wasprime: # a run has ended

%o endn, endp = n-1, wasprime

%o yield startn, startp, endn, endp, rl

%o an = smp if an == 2*smp else smc

%o wasprime = 0 # False

%o else:

%o if not wasprime: # a run has started

%o startn, startp, rl = n, an, 1

%o else: rl += 1

%o wasprime = an

%o an = smp if smp < smc else smc

%o if an == smp: smp = nextprime(smp)

%o else:

%o smc += 1

%o while isprime(smc): smc += 1

%o print([out[0] for out in list(islice(A376750_4gen(), 15))]) # _Michael S. Branicky_, Oct 03 2024

%Y Cf. A376198-A376201, A376751-A376754.

%K nonn

%O 1,1

%A _N. J. A. Sloane_, Oct 03 2024

%E a(14)-a(33) from _Michael S. Branicky_, Oct 04 2024

%E a(34)-a(36) from _Michael S. Branicky_, Oct 07 2024