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

66.67% Correct | 33.33% Incorrect
Last Solution submitted on Aug 26, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers3

Suggested Problems

More from this Author271

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!