The Smarandache prime-digital sequence (SPDS for brevity) is the sequence of primes whose digits are themselves prime.

For example 257 is an element of this sequence because it is prime itself and its digits: 2, 5 and 7 are also prime.

Task
 Show the first 25 SPDS primes.
 Show the hundredth SPDS prime.


See also

 OEIS A019546: Primes whose digits are primes.
 https://www.scribd.com/document/214851583/On-the-Smarandache-prime-digital-subsequence-sequences


 
load "stdlib.ring"
 
see "First 25 Smarandache primes:" + nl + nl
 
num = 0
limit = 26
limit100 = 100
for n = 1 to 34000
    flag = 0
    nStr = string(n)
    for x = 1 to len(nStr)
        nx = number(nStr[x])
        if isprime(n) and isprime(nx)
           flag = flag + 1
        else
           exit
        ok
     next
     if flag = len(nStr)
        num = num + 1
        if num < limit
           see "" + n + " "
        ok
        if num = limit100
           see nl + nl + "100th Smarandache prime: " + n + nl
        ok
     ok
next
 