login
a(n) is the least number of successive numbers 1, 2, 3, ... which when added to n produce a prime number.
1

%I #21 Oct 21 2014 16:47:50

%S 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,

%T 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,

%U 1,3,2,4,1,8,1,3,5,7,2,3,1,4,2,7,1,3

%N a(n) is the least number of successive numbers 1, 2, 3, ... which when added to n produce a prime number.

%C 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

%C Do we know that a(n) always exists? - _N. J. A. Sloane_, Oct 20 2014

%C Conjecturally (Hardy & Littlewood conjecture F), a(n) exists for all n. - _Charles R Greathouse IV_, Oct 21 2014

%H Vincenzo Librandi, <a href="/A249061/b249061.txt">Table of n, a(n) for n = 0..1000</a>

%e a(1)=1 because 1+[1]=2 which is prime.

%e a(2)=1 because 2+[1] =3 which is prime.

%e a(3)=4 because 3+[1+2+3+4]=13 which is prime, and intermediate sums are composite.

%t 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 *)

%o (PARI) a(n) = {k=1; while (!isprime(n + k*(k+1)/2), k++); k;} \\ _Michel Marcus_, Oct 21 2014

%K nonn,easy

%O 0,1

%A _Gil Broussard_, Oct 20 2014

%E Definition edited by _N. J. A. Sloane_, Oct 20 2014

%E Mathematica code adapted to the offset by _Vincenzo Librandi_ Oct 21 2014