(PARI) /* k primes - kprimes.gp. Primes containing or not containing digit k=1, 2, 3...9, 10, 11... PARI does not have a good string manipulation capability. This program circumvents that by using the % modulo and floor operators. Also commented out is a log implementation which is slower than string apps. The program either masks out prime numbers k or masks them in.*/
(PARI) log10(z) = if(z>0, floor(log(z)/log(10))+1, 1); \\integer function for log(z) base 10 + 1
{ kprimes(n1, n2, k, t) = \\n1, n2=range, k=mask, t=0 mask out t=1 mask in
ct=0; pct=0; forprime(p=n1, n2, x=p; f=0; \\x=temp variable to diminish p
ln = length(Str(p)); \\get length of the prime p using strings
lk = length(Str(k)); \\get length of mask integer k using strings
ln = log10(p); \\get length of the prime p using logs
lk = log10(k); \\get length of mask integer k using strings
r = 10^lk; \\set the remainder length = length of k
for(j=1, ln-lk+1, \\permute through the digits
d = x % r; \\get lk digits
if(d==k, f=1; break); \\break for loop if match and set flag
x = floor(x/10); \\diminish x for next test for k
); if(f==t, print1(p" "); ct+=1); \\if no k string of digits, print
); print(); print(ct); }
(PARI) hasNo13(n)=n=digits(n); for(i=2, #n, if(n[i]==3&&n[i-1]==1, return(0))); 1
(Haskell)
import Data.List (isInfixOf)
a076805 n = a076805_list !! (n-1)
a076805_list = filter (not . ("13" `isInfixOf`) . show) a000040_list