JohnataDavi / sieve-of-eratosthenes

C++ implementation of the eratosthenes sieve using control and data parallelism.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Sieve of Eratosthenes


C++ implementation of the eratosthenes sieve using control and data parallelism.

Sieve of Eratosthenes is a simple and ancient algorithm used to find the prime numbers up to any given limit. It is one of the most efficient ways to find small prime numbers.

For a given upper limit nn the algorithm works by iteratively marking the multiples of primes as composite, starting from 2. Once all multiples of 2 have been marked composite, the muliples of next prime, ie 3 are marked composite. This process continues until p ≤ √n where p is a prime number.

sieve-of-eratosthenes
Algorithm steps for primes below 121.

Requirements

  • C++ 14/17 or later
  • OpenMp
  • Optional:
    • Linux
## CMakeLists 
cmake_minimum_required(VERSION 3.17)
project(SieveEratosthenes)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fopenmp")
add_executable(your_file.cpp)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

About

C++ implementation of the eratosthenes sieve using control and data parallelism.


Languages

Language:C++ 93.7%Language:CMake 6.3%