A330248 a(1) = 1; for n > 1, a(n) is the least nonnegative number such that a(n) + a(n-1) + n is a prime number.
1, 0, 0, 1, 1, 0, 0, 3, 1, 0, 0, 1, 3, 0, 2, 1, 1, 0, 0, 3, 5, 2, 4, 1, 3, 0, 2, 1, 1, 0, 0, 5, 3, 0, 2, 3, 1, 2, 0, 1, 1, 0, 0, 3, 5, 2, 4, 1, 3, 0, 2, 5, 1, 4, 0, 3, 1, 0, 0, 1, 5, 0, 4, 3, 3, 2, 2, 1, 1, 0, 0, 1, 5, 0, 4, 3, 3, 2, 2, 1, 1, 0, 0, 5, 7, 4, 6
Offset: 1
Keywords
Examples
When n=5, a(4)=1; we want a(5)+a(4)+5 to be a prime. 1 is the least nonnegative number that satisfies this condition (1+5+1=7). So, a(5)=1.
Crossrefs
Cf. A062042.
Programs
-
Mathematica
Nest[Append[#1, Block[{k = 0}, While[! PrimeQ[#1[[-1]] + k + #2], k++]; k]] & @@ {#, Length@ # + 1} &, {1}, 105] (* Michael De Vlieger, Dec 14 2019 *)
-
PARI
for (n=1, 87, print1 (v=if (n==1, 1, nextprime(n+v)-n-v)", ")) \\ Rémy Sigrist, Dec 06 2019
Comments