Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Delicate primes

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 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 , 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 I/Os rather than the method, that either:

  • is shorter than a naive 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.

Answer*

Draft saved
Draft discarded
Cancel
1
  • 1
    \$\begingroup\$ Really like </@ here. Since it's a decision problem you can get 23 bytes \$\endgroup\$ Commented Sep 20, 2020 at 21:57

AltStyle によって変換されたページ (->オリジナル) /