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


func IsPrime(N);        \Return 'true' if N is prime
int  N, I;
[if N <= 2 then return N = 2;
if (N&1) = 0 then \even >2\ return false;
for I:= 3 to sqrt(N) do
    [if rem(N/I) = 0 then return false;
    I:= I+1;
    ];
return true;
];
 
func PrimeDigits(N);    \Return 'true' if all digits are prime
int  N;
[repeat N:= N/10;
        case rem(0) of
          0, 1, 4, 6, 8, 9: return false
        other [];
until   N = 0;
return true;
];
 
int C, N;
[C:= 0;  N:= 2;
loop    [if IsPrime(N) then
            if PrimeDigits(N) then
                [C:= C+1;
                if C <= 25 then
                    [IntOut(0, N);  ChOut(0, ^ )];
                if C = 100 then
                    [Text(0, "^m^j100th: ");  IntOut(0, N)];
                if C = 1000 then quit;
                ];
        N:= N+1;
        ];
Text(0, "^m^j1000th: ");  IntOut(0, N);  CrLf(0);
]