login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A072943
Least nonnegative integer k such that n + k^3 is prime, or -1 if no such k exists.
1
1, 0, 0, 1, 0, 1, 0, -1, 2, 1, 0, 1, 0, 3, 2, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 3, -1, 1, 0, 1, 0, 3, 2, 3, 2, 1, 0, 5, 2, 1, 0, 1, 0, 3, 2, 1, 0, 5, 4, 11, 2, 1, 0, 5, 6, 3, 8, 1, 0, 1, 0, 3, 2, -1, 2, 1, 0, 5, 10, 1, 0, 1, 0, 3, 2, 3, 6, 1, 0, 3, 2, 1, 0, 13, 4, 3, 4, 1, 0, 7, 6, 9, 2, 9, 2, 1, 0, 5, 2, 1
OFFSET
1,9
COMMENTS
For n = 2^3, 3^3, 4^3,...., a(n) = -1 since, say, 2^3 + k^3 cannot be prime for nonnegative k (it can be factored by the sum of cubes formula).
a(n) = 0 if and only if n is prime. - Iain Fox, Dec 29 2017
EXAMPLE
a(9) = 2 since k = 2 is the least nonnegative integer such that 9 + k^3 is prime.
MATHEMATICA
Array[Which[PrimeQ@ #, 0, And[# > 1, IntegerQ@ Power[#, 1/3]], -1, True, Block[{k = 1}, While[! PrimeQ[# + k^3], k++]; k]] &, 100] (* Michael De Vlieger, Dec 30 2017 *)
PROG
(PARI) a(n) = if(round(n^(1/3))^3 == n && n!=1, return(-1)); for(k=0, +oo, if(isprime(n + k^3), return(k))) \\ Iain Fox, Dec 29 2017
CROSSREFS
Sequence in context: A229297 A116675 A123022 * A372596 A072175 A280712
KEYWORD
sign
AUTHOR
Joseph L. Pe, Aug 14 2002
STATUS
approved