Inspired by Find the largest fragile prime.
By removing at least 1 digit from a positive integer, we can get a different non-negative integer. Note that this is different to the Remove
function in the linked question. We say a prime number is delicate if all integers generated this way are not prime. For example, \$60649\$ generates the following integers:
0, 4, 6, 9, 49, 60, 64, 66, 69, 604, 606, 609, 649, 664, 669, 6049, 6064, 6069, 6649
None of these integers are prime, therefore \$60649\$ is a delicate prime. Note that any leading zeros are removed, and that the requirement is "not prime", so \$0\$ and \$1\$ both qualify, meaning that, for example, \$11\$ is a delicate prime.
Similar to the standard sequence rule, you are to do one of the following tasks:
- Given a positive integer \$n\$, output two distinct, consistent* values depending on whether \$n\$ is a delicate prime or not
- Given a positive integer \$n\$, output the \$n\$th delicate prime
- Given a positive integer \$n\$, output the first \$n\$ delicate primes
- Output infinitely the list of delicate primes
*: You may choose to output two sets of values instead, where the values in the set correspond to your language’s definition of truthy and falsey. For example, a Python answer may output an empty list for falsey/truthy and a non-empty list otherwise.
You may choose which of the tasks you wish to do.
You can input and output in any standard way, and, as this is code-golf, shortest code in bytes wins
For reference, the first 20 delicate primes are:
2, 3, 5, 7, 11, 19, 41, 61, 89, 409, 449, 499, 881, 991, 6469, 6949, 9001, 9049, 9649, 9949
A couple more to look out for:
821 - False (Removing the 8 and the 1 gives 2 which is prime)
I'll offer a +100 bounty for an answer which implements one of the standard sequence I/Os rather than the decision-problem method, that either:
- is shorter than a naive decision-problem implementation (please include such a version as proof if one hasn't already been posted)
- or that doesn't rely on checking whether values are delicate primes or not when generating values (e.g. may use the fact that only specific digits can occur, or something else that isn't simply slapping a "loop over numbers, finding delicate primes")
This is kinda subjective as to what counts as "checking for delicate primes", so I'll use my best judgement when it comes to awarding the bounty.