A225765 Least k>0 such that k^3+n is prime, or 0 if there is no such k.
1, 1, 2, 1, 2, 1, 4, 0, 2, 1, 2, 1, 6, 3, 2, 1, 6, 1, 4, 3, 2, 1, 2, 5, 4, 3, 0, 1, 2, 1, 10, 3, 2, 3, 2, 1, 4, 5, 2, 1, 6, 1, 4, 3, 2, 1, 6, 5, 4, 11, 2, 1, 2, 5, 6, 3, 8, 1, 2, 1, 6, 3, 2, 0, 2, 1, 4, 5, 10, 1, 2, 1, 4, 3, 2, 3, 6, 1, 24, 3, 2, 1, 12, 13, 4
Offset: 1
Keywords
Examples
a(7)=4 because 1^3+7=8, 2^3+7=15, 3^3+7=34 are all composite, but 4^3+7=71 is prime. a(8)=0 because x^3+8 = (x+2)(x^2-2x+4) is composite for all integer values x>0.
Programs
-
PARI
A225765(a,b=3)={#factor(x^b+a)~==1&for(n=1,9e9,ispseudoprime(n^b+a)&return(n));a==1&return(1);print1("/*"factor(x^b+a)"*/")} \\ For illustrative purpose only: the polynomial is factored to avoid an infinite search loop when it is composite. But this does not exclude that all but one factors might equal 1, therefore the factorization is printed for control before 0 is returned.
-
PARI
a(n) = {if ((n!=1) && ispower(n, 3), return (0)); k = 1; while (! isprime(k^3+n), k++); k;} \\ Michel Marcus, Nov 10 2014
Extensions
More terms from Michel Marcus, Nov 10 2014
Comments