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.

Showing 1-3 of 3 results.

A227217 Primes p such that p + (product of digits of p) is prime and p - (product of digits of p) is prime.

Original entry on oeis.org

23, 29, 83, 101, 103, 107, 109, 293, 307, 347, 349, 401, 409, 431, 439, 503, 509, 601, 607, 653, 659, 677, 701, 709, 743, 809, 907, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1123, 1201, 1297, 1301, 1303, 1307, 1409, 1423, 1489, 1523
Offset: 1

Views

Author

Derek Orr, Sep 19 2013

Keywords

Comments

Intersection of A157677 and A225319.
Contains A056709. - Robert Israel, Apr 13 2015

Examples

			431 is prime, 431 + (4*3*1) = 443 is prime, and 431 - (4*3*1) = 419 is prime. So, 431 is a term in the sequence.
		

Crossrefs

Programs

  • Maple
    filter:= proc(n) local m;
      if not isprime(n) then return false fi;
      m:= convert(convert(n,base,10),`*`);
      if m = 0 then return true fi;
      isprime(n+m) and isprime(n-m)
    end proc:
    select(filter, [seq(2*i+1,i=5..10000)]); # Robert Israel, Apr 13 2015
  • Mathematica
    fQ[n_] := Block[{d = IntegerDigits@ n}, PrimeQ[n + Times @@ d] && PrimeQ[n - Times @@ d]]; Select[Prime@ Range@ 250, fQ] (* Michael De Vlieger, Apr 12 2015 *)
  • PARI
    forprime(p=1,2000,d=digits(p);P=prod(i=1,#d,d[i]);if(isprime(p+P)&&isprime(p-P),print1(p,", "))) \\ Derek Orr, Apr 10 2015
  • Python
    from sympy import isprime, primerange
    def DP(n):
        p = 1
        for i in str(n):
            p *= int(i)
        return p
    for pn in primerange(1, 2000):
        dpn = DP(pn)
        if isprime(pn-dpn) and isprime(pn+dpn):
            print(pn, end=', ')
    # Simplified by Derek Orr, Apr 10 2015
    
  • Sage
    [p for p in primes_first_n(1000) if ((p-prod(Integer(p).digits(base=10))) in Primes() and (p+prod(Integer(p).digits(base=10))) in Primes())] # Tom Edgar, Sep 19 2013
    

Extensions

More terms from Derek Orr, Apr 10 2015

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
    

A225677 Primes of the form p - (product of digits of p), where p is a prime.

Original entry on oeis.org

11, 17, 19, 31, 37, 59, 101, 103, 107, 109, 113, 173, 179, 193, 199, 211, 227, 233, 239, 241, 257, 263, 307, 311, 317, 331, 383, 389, 397, 401, 409, 419, 439, 479, 499, 503, 509, 521, 547, 563, 571, 577, 601, 607, 613, 617, 659, 691, 701, 709, 719, 733, 809
Offset: 1

Views

Author

Jayanta Basu, May 12 2013

Keywords

Comments

Primes generated by A225319.

Examples

			17 is in the list since 17 = 23 - (2*3).
		

Crossrefs

Programs

  • Mathematica
    Union[Select[Table[p=Prime[n]; p-Times@@IntegerDigits[p],{n,150}],PrimeQ]]
Showing 1-3 of 3 results.