Well, the librarian caught you cheating at your job by using your sorting algorithm, so now you're being punished. You've been ordered to create some code so the librarian can impress the object of their unrequited affection, the math teacher. So that's what "Other duties as assigned" means ...
Everyone is familiar with the natural number sequence in base 10, called \$\mathbb N\$:
0, 1, 2, 3, 4, 5, 6, ...
From that, we can generate the prime number sequence, let's call it \$\mathbb P\$, such that every element in \$\mathbb P\$ has exactly two divisors in \$\mathbb N\$, namely 1
and itself. This sequence is:
2, 3, 5, 7, 11, 13, ...
OK, pretty routine so far.
The librarian thought of a nifty function \$F(x, y)\$ that takes a number \$x\$ from \$\mathbb N\$, with the condition \$0 \le x \le 9\$, and a number \$y\$ from \$\mathbb N\$, and inserts \$x\$ into \$y\$'s decimal expansion in every position (i.e., prepending, inserting, or appending \$x\$ into \$y\$), then returns the sorted set of new numbers.
For example, \$F(6, 127)\$ would result in
1267, 1276, 1627, 6127
That's still kinda boring, though. The librarian wants to spice things up a bit more by instead specifying a new function \$z \to \{p : p \in \mathbb P , F(z,p) \subset \mathbb P\}\$, sorted ascending.
For example, \$z(7)\$ would be
3, 19, 97, 433, 487, 541, ...
because \$37\$ and \$73\$ are both prime, \$719\$, \$179\$ and \$197\$ are all prime, etc.
Note that \$z(2)\$ is empty, because no prime that has a \$2\$ appended will ever still be prime. Similarly for \$\{0,4,5,6,8\}\$.
Your task is to write code that will generate and output the first 100 numbers in sequence \$z(x)\$ for a given \$x\$.
Input
A single integer \$x\$ such that \$0 \le x \le 9\$. Input can be via function argument, STDIN, or equivalent.
Output
A sequence of the first 100 numbers, delimited by your choosing, to STDOUT or equivalent, such that the sequence satisfies \$z(x)\$ as described above. If \$z(x)\$ is empty, as is the case for \$\{0,2,4,5,6,8\}\$, the words Empty Set
should be output instead.
Restrictions
- This is code-golf, since you'll need to transcribe this to an index card so the librarian can show the math teacher, and your hand cramps easily.
- Standard loophole restrictions apply. The librarian doesn't tolerate cheaters.
Reference sequences
x=1 : A069246
x=3 : A215419
x=7 : A215420
x=9 : A215421
Related: Find the largest fragile prime / Find the smallest prime from a substring / Find largest prime which is still a prime after digit deletion