cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A231979 Numbers n such that for every digit d in n, 2*n + 6*d - 3 is prime.

Original entry on oeis.org

1, 2, 4, 5, 7, 8, 10, 13, 17, 19, 22, 29, 32, 34, 37, 43, 44, 50, 52, 55, 65, 67, 70, 77, 83, 89, 112, 113, 115, 118, 124, 127, 133, 145, 152, 155, 167, 172, 182, 188, 199, 200, 215, 229, 274, 277, 295, 302, 308, 322, 362, 379, 400, 418, 433, 488, 494, 499
Offset: 1

Views

Author

John R Phelan, Nov 16 2013

Keywords

Comments

The coefficients 2,6,-3 yield more hits between 1 and 1000000 than 2,2,1 or 1,1,1.

Examples

			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.
		

Programs

  • 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;
    }
    }
  • Mathematica
    fQ[n_] := Module[{d = IntegerDigits[n]}, And @@ PrimeQ[2*n + 6*d - 3]]; Select[Range[1000], fQ] (* T. D. Noe, Nov 19 2013 *)