OFFSET
1,1
EXAMPLE
11 is in the sequence because distances to the nearest square and cube (9 and 8) are prime numbers.
PROG
(Java)
import java.math.*;
public class A234799 {
public static void main (String[] args) {
for (long k = 1; ; k++)
if (BigInteger.valueOf(k).isProbablePrime(50)) {
long r2 = (long)Math.sqrt(k);
if (r2*r2==k) continue;
long r3 = (long)Math.cbrt(k);
if (r3*r3*r3==k) continue;
long b2 = r2*r2, a2 = (r2+1)*(r2+1);
long b3 = r3*r3*r3, a3 = (r3+1)*(r3+1)*(r3+1);
long s = (k-b2<=a2-k)? b2 : a2;
long c = (k-b3<=a3-k)? b3 : a3;
long nrst2 = Math.abs(s-k);
long nrst3 = Math.abs(c-k);
if (s!=c &&
BigInteger.valueOf(nrst2).isProbablePrime(50) &&
BigInteger.valueOf(nrst3).isProbablePrime(50))
System.out.printf("%d, ", k);
}
}
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Alex Ratushnyak, Dec 30 2013
STATUS
approved