Problem 60786. Count the primes resulting from changing one digit of a number
If you start with the number 24 and seek primes by changing a single digit, you can find two: 23 and 29. If you start with 130, you can find three: 131, 137, and 139. If you start with 73, you can find seven: 13, 23, 43, 53, 71, 79, and 83. Notice that even though 73 is prime, it does not register in the count because a digit has not been changed.
Write a function that takes a number as input and determine the number of change-a-digit primes that can be found. Remember that only one digit at a time can be changed. Also, the numbers may not have leading zeros.
Solution Stats
Problem Comments
-
2 Comments
Christian Schröder
on 16 Jan 2025
If you change the first digit of 73 from a 7 to a 0, you also get a prime - but here, we only consider primes with the same number of digits as the original number, correct?
ChrisR
on 16 Jan 2025
Correct.
Solution Comments
Show commentsProblem Recent Solvers4
Suggested Problems
More from this Author291
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!