OpenBSD Handbook

Current snapshot · amd64 · Generated 2026-09-09

p5-Math-Prime-Util-0.74

utilities related to prime numbers, including fast sieves

Back to search · Project homepage

Description

A module for number theory in Perl. This includes prime sieving, primality tests, primality proofs, integer factoring, counts / bounds / approximations for primes, nth primes, and twin primes, random prime generation, and much more. This module is the fastest on CPAN for almost all operations it supports. This includes Math::Prime::XS, Math::Prime::FastSieve, Math::Factor::XS, Math::Prime::TiedArray, Math::Big::Factors, Math::Factoring, and Math::Primality (when the GMP module is available). For numbers in the 10-20 digit range, it is often orders of magnitude faster. Typically it is faster than Math::Pari for 64-bit operations. All operations support both Perl UV's (32-bit or 64-bit) and bignums. If you want high performance with big numbers (larger than Perl's native 32-bit or 64-bit size), you should install Math::Prime::Util::GMP and Math::BigInt::GMP. This will be a recurring theme throughout this documentation -- while all bignum operations are supported in pure Perl, most methods will be much slower than the C+GMP alternative. The module is thread-safe and allows concurrency between Perl threads while still sharing a prime cache. It is not itself multi-threaded. See the Limitations section if you are using Win32 and threads in your program. Also note that Math::Pari is not thread-safe (and will crash as soon as it is loaded in threads), so if you use Math::BigInt::Pari rather than Math::BigInt::GMP or the default backend, things will go pear-shaped. Two scripts are also included and installed by default: * primes.pl displays primes between start and end values or expressions, with many options for filtering (e.g. twin, safe, circular, good, lucky, etc.). Use --help to see all the options. * factor.pl operates similar to the GNU factor program. It supports bigint and expression inputs.

Package information

Ports path
math/p5-Math-Prime-Util
Package architecture
amd64
Maintainer
The OpenBSD ports mailing-list <ports@openbsd.org>
Categories
math, perl5
Available flavors
None listed

These are ports metadata. Binary availability depends on the release, architecture and mirror. Build and test dependencies are not an installation checklist.

Direct dependencies

Runtime

Test

Used by (2 dependency relationships)

Includes library, runtime, build and test relationships. Results load 100 at a time.

Installing and updating packages · Package details as JSON