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

100.0% Correct | 0.0% Incorrect
Last Solution submitted on Sep 17, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers7

Suggested Problems

More from this Author280

Problem Tags

Community Treasure Hunt

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

Start Hunting!