OFFSET
1,1
LINKS
Jens Kruse Andersen and Giovanni Resta, Table of n, a(n) for n = 1..45 (first 38 terms from Jens Kruse Andersen)
Jens Kruse Andersen, Consecutive Congruent Primes
FORMULA
a(n) = A289118(n) if and only if n > 1 and A289118(n) < A289118(n+1). - Jonathan Sondow, Jun 27 2017
EXAMPLE
a(4)=23 because 23,29,31,37 alternate 4*n+3,4*n+1,4*n+3,4*n+1 for exactly four primes and 23 is the least prime for a string of exactly four.
MAPLE
Primes:= select(isprime, [seq(2*i+1, i=1..10^7)]):
Pm4:= map(`modp`, [seq((-1)^j*Primes[j], j=1..nops(Primes))], 4):
Starts:= [1, op(select(t -> Pm4[t-1]<> Pm4[t], [$2..nops(Pm4)]))]:
Lengths:= [seq(Starts[i+1]-Starts[i], i=1..nops(Starts)-1)]:
for i from 1 to max(Lengths) do A[i]:= ListTools:-Search(i, Lengths) od:
R:=[seq(A[i], i=1..max(Lengths))]:
seq(`if`(a=0, 0, Primes[Starts[a]]), a=R); # Robert Israel, Sep 15 2014
MATHEMATICA
i = 2; While[ Mod[ Prime[i] - Prime[i - 1], 4] != 0 || Mod[ Prime[i + 1] - Prime[i], 4] != 0, i++]; T = {Prime[i]}; Do[j = 2; While[! (Product[ Mod[ Prime[k + 1] - Prime[k], 4], {k, j, j + n}] != 0 && (Mod[Prime[j] - Prime[j - 1], 4] == 0 || j == 2) && Mod[ Prime[j + n + 2] - Prime[j + n + 1], 4] == 0), j++]; T = Append[T, Prime[j]], {n, 0, 13}]; T (* Jonathan Sondow, Jun 28 2017 *)
PROG
(PARI) v=vector(100); v[1]=7; cur=1; p=3; forprime(q=5, 1e10, if((q-p)%4==0, if(!v[cur], v[cur]=back(p, cur); print("a("cur") = "v[cur])); cur=1, cur++); p=q) \\ Charles R Greathouse IV, Sep 15 2014
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot, Sep 15 2014
EXTENSIONS
More terms from Jens Kruse Andersen, Oct 01 2014
Definition clarified by Jonathan Sondow, Jun 25 2017
STATUS
approved