/PrimesList

Simple Python module for the time analysis of different possible approaches to primes list computation

Primary LanguagePython

PrimesList

This python script analyzes and compares three different approaches to calculating the list of primes up to a given number:

  1. The simplest and possibly worst algorithm
  2. A polished and more efficient version of the previous algorithm, but still naive
  3. The sieve of Eratosthenes algorithm
  4. The sieve of Atkin, which has a theoretical better performance than the other algorithms, but actually depends on the implementation used. See here for an efficient code implementation

the list of primes up to 10000 is computed 5 times for each algorithm and the execution time is measured and printed

Some profiling of the execution time are then computed and plotted with the help of matplotlib

How to compile and execute the code

Save the source code file prime_numbers.py in a folder on your computer. Open a terminal and navigate to you folder with the command cd, then run the command

python3 prime_numbers.py