Math::N...lePrimes(3)

πŸ“¦
version 75 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Math::NumSeq::DeletablePrimes β€” bestie, these are the deletable primes, aka primes where you can yeet a digit and still be left with a prime that is also deletable. It's giving recursive slay. πŸ¦‹

Oh and btw, the manual name is Math::N...lePrimes(3), filed under User Contributed Perl Documentation, iykyk.


✨ SYNOPSIS ✨

use Math::NumSeq::DeletablePrimes;
my $seq = Math::NumSeq::DeletablePrimes->new;
my ($i, $value) = $seq->next;

That's literally it. Three lines. Main character energy. πŸ‘‘


🌸 DESCRIPTION 🌸

Okay so. The deletable primes are primes where you can remove a digit and get another prime β€” and that prime has to be deletable too. It's primes all the way down, no cap. πŸ’…

2, 3, 5, 7, 13, 17, 23, 29, 31, 37, 43, ...     (A080608)
starting i=0

Take 367 for example β€” it's a deletable prime because you can delete the 6 and get prime 37, and then from 37 you delete the 3 and get prime 7. Chain complete, gorgeous, iconic. πŸŽ€

And like, there can be more than one chain of deleted digits, which is so extra of it. Same 367? Instead delete the 3 and you get 67, then on to 7. Two paths, both valid, we love a flexible queen.

Since every chain bottoms out at a single-digit prime β€” that's 2, 3, 5 or 7 β€” literally every value has at least one such digit in its ancestry. Periodt.

Leading zeros are not allowed, bestie. So the high digit cannot be deleted if it's followed by a zero. Example: 2003 is not a deletable prime. Deleting the 2 gives 003 and that's not allowed (even though it would be a prime, sad), and the other deletes to 203 or 200? Not primes. Sorry girl. 😭

πŸ”’ Radix

Optional parameter radix picks a base other than decimal, for when you're feeling spicy. For binary radix=>2, the primes 2 and 3 β€” which are two bits, "10" and "11" β€” get reckoned as endpoints, in the manner of OEIS A096246, since there are no one-bit primes. So they're the floor of the whole thing. 🫢


🧚 FUNCTIONS 🧚

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes. The shared lore, if you will.

  • $seq = Math::NumSeq::DeletablePrimes->new ()
  • $seq = Math::NumSeq::DeletablePrimes->new (radix => $integer)

Create and return a new sequence object. Fresh out of the box, ready to serve. ✨

  • $bool = $seq->pred($value)

Return true if $value is a deletable prime, in the selected radix. Vibe check: passed or not.

Real talk though β€” in the current code there's a hard limit of 2**32 placed on the $value to be checked, in the interests of not going into a near-infinite loop. So don't come at it with a gigantic number, it will simply not. πŸ’€

πŸ‘€ SEE ALSO πŸ‘€

  • Math::NumSeq
  • Math::NumSeq::Primes
  • Math::NumSeq::SophieGermainPrimes

Go read those too, they're all part of the same friend group. 🌈


This whole page came to you courtesy of perl v5.42.0, dated 2025-07-25, under the name Math::N...lePrimes(3). Bye bestie, go delete some digits responsibly! πŸ’œπŸŒΈπŸŽ€

πŸ“¦ where this page comes from