Math::N...:Primes(3)
π Math::N...:Primes β prime numbers π
okay bestie, so this is a page from the User Contributed Perl Documentation (yes it really says Math::N...:Primes(3) at the top, that's not a typo, that's just how the header truncates it, slay) and it's literally about the most iconic sequence in all of math. primes. periodt.
β¨ NAME β¨
Math::NumSeq::Primes β prime numbers π
πΈ SYNOPSIS πΈ
use Math::NumSeq::Primes;
my $seq = Math::NumSeq::Primes->new;
my ($i, $value) = $seq->next;
that's it. that's the whole vibe. create the sequence, ask for the next thing, get numbers. no cap. π¦
π DESCRIPTION π
okay so. the prime numbers. they're the numbers that aren't divisible by anything except themselves and 1. like they refuse to be broken down. main character energy fr fr. β¨
2, 3, 5, 7, 11, 13, 17, 19, ... (A000040)
starting i=1
(yes the OEIS number is A000040, iykyk π)
right now, this is implemented with Math::Prime::XS, which generates blocks of primes using a sieve of Eratosthenes. the result is reasonably progressive, so it's not just sitting there doing nothing while you wait. π«Ά
β οΈ on a 32-bit system there's a hard limit at 2^31 β though honestly, even approaching that number takes a really long time to calculate. like, go get a snack. maybe two. π
π FUNCTIONS π
peep "FUNCTIONS" in Math::NumSeq for the behaviour that's common to all the sequence classes, because those are shared bestie behaviour. π
$seq = Math::NumSeq::Primes->new ()β creates and returns a brand new sequence object. your own personal prime generator. obsessed. β¨$bool = $seq->pred($value)β returns true if$valueis a prime. π―
in the current code there's a hard limit of2**32on the$valueyou're checking, and that's specifically in the interests of not going into a near-infinite loop. so don't test your luck past that, bestie. π
$i = $seq->value_to_i_estimate($value)β returns an estimate of theithat corresponds to$value.$valuecan be any size here, it's not limited like it is inpred(). check out "Value to i Estimate" down below for the deets. π
π FORMULAS π
β Value to i Estimate β
in the current code, the number of count of primes up to value is estimated by the well-known asymptotic:
i ~= value/log(value)
that's the formula, that's the whole thing, she's simple and she works. π§
π¦ SEE ALSO π¦
Math::NumSeqMath::NumSeq::TwinPrimesMath::NumSeq::SophieGermainPrimesMath::NumSeq::EmirpsMath::Prime::XSMath::Prime::TiedArrayMath::Prime::FastSieveMath::Prime::Util
go read them, they're all part of the same little universe. πΈ
π HOME PAGE π
<http://user42.tuxfamily.org/math-numseq/index.html>
π LICENSE π
copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019, 2020 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. π«Ά
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. see the GNU General Public License for more details. π
you should have received a copy of the GNU General Public License along with Math-NumSeq. if not, peep <http://www.gnu.org/licenses/>. π
okay that's the whole page bestie, no skips, no skims, every single detail accounted for. π
this was perl v5.42.0, dated 2025-07-25 β love that for us. stay iconic, stay prime. π
β¨π
π¦ where this page comes from
- fedora 43: perl-Math-NumSeq 75-11.fc43 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms