login

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

a(n) is the least prime number such that prime(n)+a(n)+1 is a prime or -1 if no such prime number exists.
1

%I #60 May 09 2021 08:18:24

%S 2,3,5,3,5,3,5,3,5,7,5,3,5,3,5,5,7,5,3,7,5,3,5,7,3,5,3,5,3,13,3,5,11,

%T 11,7,5,5,3,5,5,11,11,5,3,13,11,11,3,5,3,5,11,29,5,5,5,7,5,3,11,23,13,

%U 3,5,3,13,5,11,5,3,5,7,5,5,3,5,7,3,7,11,11

%N a(n) is the least prime number such that prime(n)+a(n)+1 is a prime or -1 if no such prime number exists.

%C If Maillet's conjecture is true, then a(n) != -1 for all n. - _Chai Wah Wu_, Aug 01 2017

%H Chai Wah Wu, <a href="/A179295/b179295.txt">Table of n, a(n) for n = 1..10000</a>

%H Wen Huang and XiaoSheng Wu, <a href="https://doi.org/10.1090/proc/13533">On the set of the difference of primes</a>, Proc. Amer. Math. Soc. 145 (2017), 3787-3793.

%H E. Maillet, <a href="https://archive.org/stream/lintermdiairede02lemogoog#page/n451/mode/2up">Réponse</a>, L’intermédiaire des math. 12 (1905), p. 108.

%e a(1) = 2, since prime(1) + 2 + 1 = 5.

%t Table[Block[{p=2}, While[!PrimeQ[Prime[n] + p + 1], p=NextPrime[p]]; p],{n, 100}] (* _Indranil Ghosh_, Jun 30 2017 *)

%o (ANS Forth)

%o \ https://github.com/Lehs/ANS-Forth-libraries

%o s" numbertheory.4th" included

%o : get_number \ p -- q

%o locals| p | 1

%o begin nextprime dup p + 1+ isprime

%o until ;

%o : list_numbers \ N --

%o locals| N | 1

%o begin nextprime dup

%o get_number cr .

%o dup N >

%o until ;

%o (PARI) a(n) = my(pn=prime(n), p=2); while(! isprime(pn+p+1), p = nextprime(p+1)); p; \\ _Michel Marcus_, Jun 30 2017

%o (Python)

%o from sympy import prime, isprime, nextprime

%o def a(n):

%o p=2

%o while not isprime(prime(n) + p + 1): p=nextprime(p)

%o return p

%o print([a(n) for n in range(1, 101)]) # _Indranil Ghosh_, Jun 30 2017

%K nonn

%O 1,1

%A _Lars-Erik Svahn_, Jun 21 2017

%E Definition clarified by _Chai Wah Wu_, Aug 01 2017

%E More terms from _Chai Wah Wu_, Aug 02 2017