Math::NumSeq::Primes -- prime numbers


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


The prime numbers, 2, 3, 5, 7, 11, 13, etc, not divisible by anything except themselves and 1.

Currently this is implemented with Math::Prime::XS generating blocks of primes for the iteration with a sieve of Eratosthenes. The result is reasonably progressive. On a 32-bit system there's a hard limit at 2^31 (though even approaching that takes a long time to calculate).


See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.

$seq = Math::NumSeq::Primes->new (key=>value,...)

Create and return a new sequence object.

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

Return true if $value is a prime.


Math::NumSeq, Math::NumSeq::TwinPrimes, Math::NumSeq::SophieGermainPrimes, Math::NumSeq::Emirps




Copyright 2010, 2011 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, see <>.