|
Algorithms_in_C++
1.0.0
Set of algorithms implemented in C++.
|
Get list of prime numbers using Sieve of Eratosthenes Sieve of Eratosthenes is an algorithm to find the primes that is between 2 to N (as defined in main). More...
#include <iostream>Functions | |
| void | sieve (uint32_t N, bool *isprime) |
| void | print (uint32_t N, const bool *isprime) |
| int | main () |
Get list of prime numbers using Sieve of Eratosthenes Sieve of Eratosthenes is an algorithm to find the primes that is between 2 to N (as defined in main).
Time Complexity : \(O(N \cdot\log N)\)
Space Complexity : \(O(N)\)
| int main | ( | ) |
| void print | ( | uint32_t | N, |
| const bool * | isprime | ||
| ) |
This function prints out the primes to STDOUT
| N | number of primes to check | |
| [in] | isprime | a boolean array of size N identifying if i^th number is prime or not |
| void sieve | ( | uint32_t | N, |
| bool * | isprime | ||
| ) |
This is the function that finds the primes and eliminates the multiples.
| N | number of primes to check | |
| [out] | isprime | a boolean array of size N identifying if i^th number is prime or not |