login
A249061
a(n) is the least number of successive numbers 1, 2, 3, ... which when added to n produce a prime number.
1
2, 1, 1, 4, 1, 3, 1, 3, 2, 4, 1, 3, 1, 3, 2, 7, 1, 3, 1, 4, 2, 4, 1, 3, 10, 3, 2, 4, 1, 12, 1, 3, 5, 4, 2, 3, 1, 3, 2, 7, 1, 3, 1, 4, 2, 7, 1, 3, 10, 4, 2, 4, 1, 3, 10, 3, 2, 4, 1, 12, 1, 3, 6, 4, 2, 3, 1, 3, 2, 4, 1, 8, 1, 3, 5, 7, 2, 3, 1, 4, 2, 7, 1, 3
OFFSET
0,1
COMMENTS
In other words, a(n) = smallest k >= 1 such that n + k(k+1)/2 is a prime. - N. J. A. Sloane, Oct 20 2014
Do we know that a(n) always exists? - N. J. A. Sloane, Oct 20 2014
Conjecturally (Hardy & Littlewood conjecture F), a(n) exists for all n. - Charles R Greathouse IV, Oct 21 2014
LINKS
EXAMPLE
a(1)=1 because 1+[1]=2 which is prime.
a(2)=1 because 2+[1] =3 which is prime.
a(3)=4 because 3+[1+2+3+4]=13 which is prime, and intermediate sums are composite.
MATHEMATICA
lst = {}; Do[k = 1; While[! PrimeQ[n + k (k + 1)/2], k++]; AppendTo[lst, k], {n, 0, 100}]; lst (* Ivan N. Ianakiev, Oct 21 2014 *)
PROG
(PARI) a(n) = {k=1; while (!isprime(n + k*(k+1)/2), k++); k; } \\ Michel Marcus, Oct 21 2014
CROSSREFS
Sequence in context: A131350 A131087 A105475 * A334178 A210209 A328649
KEYWORD
nonn,easy
AUTHOR
Gil Broussard, Oct 20 2014
EXTENSIONS
Definition edited by N. J. A. Sloane, Oct 20 2014
Mathematica code adapted to the offset by Vincenzo Librandi Oct 21 2014
STATUS
approved