We define a full prime as a prime number such that every suffix is also a prime.
Some examples of full primes are:
Let be the sum of all full primes. What are the last three digits of ?
Clarification : 2, 3, 5 and 7 are considered as full prime.
Hint : Every suffix of a full prime is a full prime.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The naive approach will be looping through all number smaller than 1 0 1 0 0 and check if they are full primes.
We can do better. By definition, every suffix must be a prime. Hence, from the base primes 2 , 3 , 5 , 7 , we can recursively generate a list of full primes by adding a digit in front of the full primes we found. This can be done with either Depth-First Search or Breadth-First Search. My approach is using a kind of BFS with the the number of digits it possess as depth.
Surprisingly, there are no full primes with 25 digits.
This code runs in about 14 seconds.