Skip to content

tristanwainwright/sieve-of-eratosthenes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sieve of Eratosthenes

Description

The Sieve of Eratosthenes is an algorithm used to find all the prime numbers between the first prime $2$ and a given limit $n$.

Usage

Build project

cargo build

Run project

cargo run -- -n <N>

Psuedocode

    algorithm Sieve of Eratosthenes is
    input: an integer n > 1.
    output: all prime numbers from 2 through n.

    let A be an array of Boolean values, indexed by integers 2 to n,
    initially all set to true.

    for i = 2, 3, 4, ..., not exceeding n do
        if A[i] is true
            for j = i2, i2+i, i2+2i, i2+3i, ..., not exceeding n do
                set A[j] := false

    return all i such that A[i] is true.

Source: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#Pseudocode

About

A prime number generator using the sieve of Eratosthenes.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages