A - Deletable Primes
A deletable prime is a prime such that you can delete the digits one at a time, in some order, and get a prime at each step. For instance, the number 4125673 is a deletable prime, since all numbers in the sequence:
are also (deletable) primes.
Our objective is to print the largest deletable prime in a given range.
The input will consist of a series of pairs of positive integers i and j, one pair of integers per line. All integers will be less than 10,000,000. You can assume that i is lesser or equal than j. You should process all pairs of integers, and for each pair determine the largest deletable prime between i and j, inclusive. Input is terminated by a line with the number -1.
For each pair of input integers, defining a range, you should output the largest deletable prime in the range, or none if no deletable primes exist in the range.