Kevin Ryde > Math-NumSeq-69 > Math::NumSeq::Primes

Math-NumSeq-69.tar.gz

Dependencies

Annotate this POD

Website

# CPAN RT

 Open 2
View/Report Bugs
Module Version: 69   Source   Latest Release: Math-NumSeq-71

# NAME

Math::NumSeq::Primes -- prime numbers

# SYNOPSIS

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

# DESCRIPTION

The prime numbers, not divisible by anything except themselves and 1.

```    2, 3, 5, 7, 11, 13, 17, 19, ...
starting i=1```

Currently this is implemented with `Math::Prime::XS` generating blocks of primes 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).

# FUNCTIONS

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

`\$seq = Math::NumSeq::Primes->new ()`

Create and return a new sequence object.

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

Return true if `\$value` is a prime.

In the current code a hard limit of 2**32 is placed on the `\$value` to be checked, in the interests of not going into a near-infinite loop.

`\$i = \$seq->value_to_i_estimate(\$value)`

Return an estimate of the i corresponding to `\$value`. `\$value` can be any size, it's not limited as in `pred()`. See "Value to i Estimate" below.

# 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)`

http://user42.tuxfamily.org/math-numseq/index.html