The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Primesieve - Perl extension for primesieve

SYNOPSIS

  use Primesieve;

  @primes = generate_primes (0,1000);

  my $iterator = Primesieve->new;
  2 == $iterator->next_prime;

DESCRIPTION

This modules gives you access to primesieve.

FUNCTIONS

$it = Primesieve->new

Creates an iterator.

$it->next_prime

Returns the next prime.

$it->prev_prime

Returns the previous prime. (Only with primesieve version >= 6.0)

$it->skipto ($start, $stop_hint)

Set the position.

@primes = generate_primes ($from, $to)

Returns a list of all primes in the specified range in list context. In scalar context an array-reference is returned.

generate_n_primes ($n, $start)

Returns a list of the first n primes >= start in list context. In scalar context an array-reference is returned.

$num = nth_prime ($n [,$start])

Find the nth prime. if n = 0 finds the 1st prime >= start, if n > 0 finds the nth prime > start, if n < 0 finds the nth prime < start (backwards).

$num = count_primes ($start, $stop)

Counts primes within the given range.

$num = count_twins ($start, $stop)

Counts twin primes within the given range.

$num = count_triplets ($start, $stop)

Counts triple primes within the given range.

$num = count_quadruplets ($start, $stop)

Counts quadruplets primes within the given range.

$num = count_quintuplets ($start, $stop)

Counts quintuplets primes within the given range.

$num = count_sextuplets ($start, $stop)

Counts sextuplets primes within the given range.

$num = print_primes ($start, $stop)

Print primes within the given range to stdout.

$num = print_twins ($start, $stop)

Print twin primes within the given range to stdout.

$num = print_triplets ($start, $stop)

Print triple primes within the given range to stdout.

$num = print_quadruplets ($start, $stop)

Print quadruplets primes within the given range to stdout.

$num = print_quintuplets ($start, $stop)

Print quintuplets primes within the given range to stdout.

$num = print_sextuplets ($start, $stop)

Print sextuplets primes within the given range to stdout.

$num = get_max_stop ()

Returns the largest valid stop number for primesieve.

$num = get_sieve_size ()

Returns the current set sieve size in KiB.

$num = get_num_threads ()

Returns the current set number of threads.

set_sieve_size ($num)

Sets the sieve size in KiB.

set_num_threads ($num)

Sets the number of threads.

SEE ALSO

AUTHOR

Stefan Traby, <stefan@hello-penguin.com>

COPYRIGHT AND LICENSE

Copyright (C) 2020 by Stefan Traby

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.28.1 or, at your option, any later version of Perl 5 you may have available.