Are there an infinite number of prime numbers where removing any number of digits leaves a prime?

It is clear that we cannot have digits $0,4,6,8,9$ in those prime numbers. There can be at most one $2$ because $22$ is composite,, at most one $3$ because $33$ is composite,at most one $5$ because $55$ is composite, at most one $7$ because $77$ is composite, at most two $1$`s because $111$ is composite, so such prime number can have at most $6$ digits so there is a finite number of such prime numbers.


To build on the earlier answers, there are exactly twenty such numbers, and they are:

1, 2, 3, 5, 7, 11, 13, 17, 23, 31, 37, 53, 71, 73, 113, 131, 137, 173, 311, 317

As can be found by the following program, which is correct as per Farewell's argument that seven digit and longer numbers cannot have the given property:

import gmpy

def test(n):
    if (not gmpy.is_prime(n)) and n != 1:
        return False
    s = str(n)
    if len(s) == 1:
        return True
    for i in xrange(len(s)):
        if not test(int(s[:i] + s[i+1:])):
            return False
    return True

print filter(test, xrange(10000000))

It is further worth noting that this program's output list is clearly exhaustive even barring Farewell's argument; the moment we fail to find any four digit examples we exclude the possibility of five digit (or longer) examples, as they must include four digit examples as substrings.


There are only finitely many, indeed there are none with more than $3$ digits. Clearly our prime cannot have $0$ as a digit.

If our prime has $4$ or more digits, and has $2$ or more not equal to $3$, we can by deleting one or two get a number greater than $3$ with digit sum divisible by $3$.

And if there are two or more $3$'s we can produce $33$.