Skip to content

Instantly share code, notes, and snippets.

View albertvanderhorst's full-sized avatar

Albert van der Horst albertvanderhorst

View GitHub Profile
@jzakiya
jzakiya / twinprimes_ssoz.d
Last active January 8, 2024 02:27
Twinprimes generator, multi-threaded, using SSoZ (Segmented Sieve of Zakiya), written in D
/* This D source file is a multiple threaded implementation to perform an
* extremely fast Segmented Sieve of Zakiya (SSoZ) to find Twin Primes <= N.
*
* Inputs are single values N, or ranges N1 and N2, of 64-bits, 0 -- 2^64 - 1.
* Output is the number of twin primes <= N, or in range N1 to N2; the last
* twin prime value for the range; and the total time of execution.
*
* Code originally developed on a System76 laptop with an Intel I7 6700HQ cpu,
* 2.6-3.5 GHz clock, with 8 threads, and 16GB of memory. Parameter tuning
* would be needed to optimize for other hadware systems (ARM, PowerPC, etc).