NAME

Math::Prime::Simple - Calculate prime numbers

SYNOPSIS

use Math::Prime::Simple qw(prime each_prime);

@ranges = (    [ 1000, 1100 ],
             [ 10000, 11000 ],
);

# primes calculation
$primes = prime( @ranges );

# primes iteration
while ($prime = each_prime( 0, $primes )) {
    print "$prime\n";
}

DESCRIPTION

Math::Prime::Simple calculates prime numbers by applying the Sieve of Eratosthenes.

FUNCTIONS

prime

Calculates prime numbers.

@ranges = (   [ 1000, 1100 ],
            [ 10000, 11000 ],
);

$primes = prime( @ranges );

Each range within @ranges will be evaluated and its prime numbers will be saved within the arrayref $primes, accessible by the array index; the prime numbers of the first range may be accessed by @{$primes->[0]}.

each_prime

Returns each prime number as string.

while ($prime = each_prime( $index, $primes )) {
    print "$prime\n";
}

$index equals the array index of @ranges.

If not all prime numbers are being evaluated by each_prime(), it is recommended to undef @{"Math::Prime::Simple::each_prime_$index"} after usage of each_prime().

EXPORT

prime(), each_prime() are exportable.