Skip to content
Some utilities related to prime numbers (in D)
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
bench update benchmark for ctprimes 1.0.1 Nov 24, 2019
source/math remove stray section header from doc Nov 24, 2019
.gitignore init Nov 24, 2019
LICENSE Initial commit Nov 24, 2019 init Nov 24, 2019
dub.sdl init Nov 24, 2019

A prime-number library for D

This module implements an infinite-primes range, and not much else.

gmp-d is efficient and fast but can't be used at compile-time.

bench/ has some simple benchmarks.


Add it as a dub dependency and consult the documentation. Here's a script that prints the first 50 primes:

#! /usr/bin/env dub
/+ dub.sdl:
    dependency "math-primes" version="~>0.1.0"

void main() {
    import math.primes: Sieve, nthPrimeUpperBound;
    import std.stdio: writeln;
    import std.range: take;

    foreach (p; Sieve!int(nthPrimeUpperBound(50)).take(50))
You can’t perform that action at this time.