OFFSET
1,2
COMMENTS
The coefficients 2,6,-3 yield more hits between 1 and 1000000 than 2,2,1 or 1,1,1.
LINKS
T. D. Noe, Table of n, a(n) for n = 1..2000
EXAMPLE
124 is in the sequence since
2*124+6*1-3=251 which is prime,
2*124+6*2-3=257 which is prime,
2*124+6*4-3=269 which is prime.
241 is NOT in the sequence since
2*241+6*2-3=491 which is prime,
2*241+6*4-3=503 which is prime,
but 2*241+6*1-3=485 which is not prime.
MATHEMATICA
fQ[n_] := Module[{d = IntegerDigits[n]}, And @@ PrimeQ[2*n + 6*d - 3]]; Select[Range[1000], fQ] (* T. D. Noe, Nov 19 2013 *)
PROG
(Java)
public class Ndp {
// 2n+6d-3 is prime for all digits d in n
private static final int MAX = 1000000;
public static void main(String[] args) {
String sequence = "";
loop: for (int n = 1; sequence.length() < 250 && n < MAX; n++) {
for (int i = n; i > 0; i /= 10) {
int d = i % 10;
if (!isPrime(2 * n + 6 * d - 3)) {
continue loop;
}
}
sequence += n + ", ";
}
System.out.println(sequence);
}
private static boolean isPrime(long n) {
for (long i = 2; i <= Math.sqrt(n); i++) {
if (n < 2 || n % i == 0) {
return false;
}
}
return true;
}
}
CROSSREFS
KEYWORD
nonn,easy,base
AUTHOR
John R Phelan, Nov 16 2013
STATUS
approved