Problem 57810. List the two-bit primes
Each year at Christmas, my father-in-law and his partner send me the Puzzle Mania section from the New York Times. This year’s edition had a puzzle by Mike Shenk called “Two Bits”, which asked solvers to find words whose first two letters could be shifted as a unit elsewhere in the word to form a new word. For example, the clue “??BID” had the answer RABID, with the accompanying word BRAID. The clue “??PREME” had the answer SUPREME, with the accompanying word PRESUME.
In a similar way, one can define two-bit primes: prime numbers whose first two digits can be shifted, as a unit, elsewhere in the number to form a new prime number. The first in the sequence is 113, with accompanying prime 311, followed by 131, with accompanying prime 113. Some two-bit primes can have multiple accompanying primes. For example, the two-bit prime 99611 has two accompanying primes: 69911 and 61991. Leading zeros are allowed: 1103 is a two-bit prime because 311 is also prime.
Remember that the two-bit prime and its accompanying prime must differ. For example, the first two digits of 99991 can be moved one or two places to the right, but the resulting number (99991) is the same. Because 99199 is not prime, 99991 is not a two-bit prime.
Write a function to list the nth two-bit and all its accompanying primes.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers6
Suggested Problems
-
Remove any row in which a NaN appears
8568 Solvers
-
356 Solvers
-
Construct an index vector from two input vectors in vectorized fashion
381 Solvers
-
Factorial: Unlimited Size : java.math
41 Solvers
-
176 Solvers
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!