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.

A229176 Primes p with nonzero digits such that p + product_of_digits and p - product_of_digits are both prime.

Original entry on oeis.org

23, 29, 83, 293, 347, 349, 431, 439, 653, 659, 677, 743, 1123, 1297, 1423, 1489, 1523, 1657, 1867, 2239, 2377, 2459, 2467, 2543, 2579, 2663, 2753, 3163, 3253, 3271, 3329, 3457, 3461, 3581, 3691, 3727, 3833, 3947, 3967, 4129, 4253, 4297, 4423, 4567, 4957, 5323, 5381, 5651
Offset: 1

Views

Author

Derek Orr, Sep 30 2013

Keywords

Comments

Numbers with nonzero digits in A227217; the non-degenerate cases, so to speak.
Intersection of primes with nonzero digits in A157677 and A225319.

Examples

			743 is prime.
743 - (7*4*3) = 659 is prime.
743 + (7*4*3) = 827 is prime.
So, 743 is a member of this sequence.
		

Crossrefs

Programs

  • Maple
    A007954 := proc(n)
        mul(d, d=convert(n, base, 10))
    end proc:
    isA229176 := proc(n)
        if isprime(n) and A007954(n) <> 0 then
            isprime(n+A007954(n)) and isprime(n-A007954(n))  ;
            simplify(%) ;
        else
            false;
        end if;
    end proc:
    for n from 1 to 10000 do
        if isA229176(n) then
            printf("%d,",n) ;
        end if;
    end do:
  • Mathematica
    id[x_] := IntegerDigits[x]; ti[x_] := Times @@ id[x]; m=5000; Select[Range[3,m,2], PrimeQ[#] && Min[id[#]] > 0 && PrimeQ[#+ti[#]] && PrimeQ[#-ti[#]]&] (* Zak Seidov, Oct 02 2013 *)
    t@n_ := Block[{p = Times @@ IntegerDigits@n},
      If[p == 0, {0}, n + {-p, p}]]; Select[Prime@Range@1000,
    AllTrue[t@#, PrimeQ] &] (* Hans Rudolf Widmer, Dec 13 2021 *)
  • PARI
    forprime(p=1,10^4,d=digits(p);P=prod(i=1,#d,d[i]);if(P&&isprime(p+P)&&isprime(p-P),print1(p,", "))) \\ Derek Orr, Mar 22 2015
  • Python
    import sympy
    from sympy import isprime
    def DP(n):
      p = 1
      for i in str(n):
        p *= int(i)
      return p
    {print(n, end=', ') for n in range(10**4) if DP(n) and isprime(n) and isprime(n+DP(n)) and isprime(n-DP(n))}
    # Simplified by Derek Orr, Mar 22 2015