Skip to content

schellingerhout/sieve-of-eratosthenes-delphi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sieve-of-Eratosthenes-Delphi

A simple implementation of the Sieve of Erastothenos for finding primes.

Very fast but memory intensive... can calculate primes up to Max(UInt32). This is the straight forward implementation, optimized as I could find, but the segmented method may allow faster implementation over multiple threads. Fork and contribute if you'd like

For details see https://schellingerhout.github.io/algorithms/sieve-of-eratosthenes/

usage

var
  LMaxValue: UInt32; // Cardinal
  LPrimes: ArrayOfUInt32;
begin
  LMaxValue := 1000000; // all primes up to LMaxValue returned
  LPrimes := TSieveOfEratosthenes.GetPrimes(LMaxValue)
end;

There is still quite a bit of optimization to be done. Feel free to fork and issue pull requests for improvements.

About

A simple implementation of the Sieve of Eratosthenes for finding primes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages