Problem 60733. Find the closest geyser prime
My wife and I celebrated our honeymoon and our recent anniversary in Yellowstone and Grand Teton National Parks. After returning from our latest trip, I made her a word puzzle involving geysers, mud pots, and canyons. Because geysers eject water and gases, a geyser in the puzzle was a word that could eject a single letter and become a new word. For example, SHORT could eject H and become SORT.
This problem deals with geyser primes, defined as prime numbers that can eject only one of their digits and become new primes. 263 is a geyser prime because it can eject the 6 (and only the 6) and become the prime 23. 10007 is a geyser prime because ejecting the 1 leads to 7 (ignore leading zeros). 251 is not a geyser prime because none of 51, 21, and 25 is prime. 197 is not a geyser prime because it can eject any one of its digits and result in a prime (97, 17, or 19). 233 is not a geyser prime because ejecting either of the 3s results in a prime. Remember that 1 is neither prime nor composite and notice the difference between geyser primes and delete-a-digit primes.
Write a function that produces the geyser prime closest to the input number. If two numbers are equally distant from the input, choose the smaller.
Solution Stats
Problem Comments
-
1 Comment
Christian Schröder
on 30 Aug 2024
Good problem, Chris!
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
6 Solvers
More from this Author279
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!