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


 
function isprime( n as ulongint ) as boolean
    if n < 2 then return false
    if n = 2 then return true
    if n mod 2 = 0 then return false
    for i as uinteger = 3 to int(sqr(n))+1 step 2
        if n mod i = 0 then return false
    next i
    return true
end function
 
dim as integer smar(1 to 100), count = 1, i = 1, digit, j
smar(1) = 2
print 1, 2
while count < 100
    i += 2
    if not isprime(i) then continue while
    for j = 1 to len(str(i))
        digit = val(mid(str(i),j,1))
        if not isprime(digit) then continue while
    next j
    count += 1
    smar(count) = i
    if count = 100 orelse count <=25 then
        print count, smar(count)
    end if
wend