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


num = 0
limit = 26
limit100 = 100
 
print "First 25 Smarandache primes:\n"
for n = 1 to 34000
    flag = 0
    nStr$ = str$(n)
    for x = 1 to len(nStr$)
        nx = val(mid$(nStr$,x,1))
        if isPrime(n) and isPrime(nx) then
           flag = flag + 1
        else
           break
        end if
     next
     if flag = len(nStr$) then
        num = num + 1
        if num < limit  print "", n, " ";
        if num = limit100  print "\n\n100th Smarandache prime: ", n
     end if
next n
end
 
sub isPrime(v)
    if v < 2  return False
    if mod(v, 2) = 0  return v = 2
    if mod(v, 3) = 0  return v = 3
    d = 5
    while d * d <= v
        if mod(v, d) = 0 then return False else d = d + 2 : fi
    wend
    return True
end sub