login
a(n) = smallest prime number between prime(n) and 2*prime(n) such that the arithmetic progression (prime(n), a(n), ...) and which contains only primes has the maximum length.
2

%I #24 Dec 25 2020 20:19:09

%S 3,5,7,13,17,17,29,31,41,41,37,67,47,61,59,71,83,67,97,131,127,103,

%T 131,101,139,197,193,137,151,173,139,191,167,151,233,181,307,271,197,

%U 233,263,211,317,283,359,211,241,373,239,271,311,359,277

%N a(n) = smallest prime number between prime(n) and 2*prime(n) such that the arithmetic progression (prime(n), a(n), ...) and which contains only primes has the maximum length.

%e a(4) = 13 since 7, 13 and 19 are primes in arithmetic progression, 7 is the fourth prime number, and there is no longer one starting with 7 than another prime less than 2*7 = 14.

%e a(12) = 67 since prime(12) = 37 and 67, 97, 127 and 157 are also primes in arithmetic progression of common difference 30.

%o (PARI) A339501(n)= {

%o my(p=prime(n), bp, bk);

%o forprime(np=p+1, 2*p, for(k=2, +oo, if(!isprime(p+k*(np-p)), if(k>bk, bk=k; bp=np;); break); ); );

%o return(bp);

%o }

%Y Cf. A000040, A339500.

%K nonn,easy

%O 1,1

%A _François Marques_, Dec 07 2020