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.

A062088 Primes with every digit a prime and the sum of the digits a prime.

Original entry on oeis.org

2, 3, 5, 7, 23, 223, 227, 337, 353, 373, 557, 577, 733, 757, 773, 2333, 2357, 2377, 2557, 2753, 2777, 3253, 3257, 3323, 3527, 3727, 5233, 5237, 5273, 5323, 5527, 7237, 7253, 7523, 7723, 7727, 22573, 23327, 25237, 25253, 25523, 27253, 27527, 32233, 32237, 32257
Offset: 1

Views

Author

Amarnath Murthy, Jun 16 2001

Keywords

Examples

			2357 is a prime, each digit is a prime and the sum of digits = 17 is also a prime, so 2357 is a term.
		

Crossrefs

Intersection of A019546 and A046704.

Programs

  • MATLAB
    prim=primes(1000000);
    m=1;
    for u=1:100;
        v=prim(u);
        nc=dec2base(v,10)-'0';
        s=sum(nc);
             if and(isprime(nc)==1,isprime(s)==1)
                 sol(m)=v;
                 m=m+1;
             end
    end
    sol; % Marius A. Burtea, Dec 08 2018
    
  • Mathematica
    aQ[p_] := PrimeQ[p] && Module[{d = IntegerDigits[p]}, PrimeQ[Total[d]] && LengthWhile[d, PrimeQ[#] &] == Length[d]]; Select[Range[33000], aQ] (* Amiram Eldar, Dec 08 2018 *)
  • PARI
    isok(p) = isprime(p) && isprime(sumdigits(p)) && (#select(x->(! isprime(x)), digits(p)) == 0); \\ Michel Marcus, Dec 08 2018
    
  • Python
    from sympy import isprime
    from itertools import count, islice, product
    def agen():
        yield from [2, 3, 5, 7]
        for d in count(2):
            for left in product("2357", repeat=d-1):
                for end in "37":
                    ts = "".join(left) + end
                    if isprime(sum(map(int, ts))):
                        t = int(ts)
                        if isprime(t): yield t
    print(list(islice(agen(), 46))) # Michael S. Branicky, Sep 23 2022

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Jun 21 2001