PRIME_SERIAL
Program to Count Primes


PRIME_SERIAL is a PYTHON program which counts the number of primes between 1 and N, and is intended as a starting point for a parallel version.

The algorithm is completely naive. For each integer I, it simply checks whether any smaller J evenly divides it. The total amount of work for a given N is thus roughly proportional to 1/2*N^2.

Licensing:

The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.

Languages:

PRIME_SERIAL is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Data and Programs:

FIRE_SERIAL, a Python program which simulates a forest fire over a rectangular array of trees, starting at a single random location. It is intended as a starting point for the development of a parallel version.

PRIME_MPI, a PYTHON script which counts the number of primes between 1 and N, using MPI for parallel execution.

QUAD_SERIAL, a PYTHON script which approximates an integral using a quadrature rule, and is intended as a starting point for parallelization exercises.

SEARCH_SERIAL, a PYTHON script which searches integers between A and B for a value J such that F(J) = C, intended as a starting point for the creation of a parallel version.

Reference:

  1. Eratosthenes,
    A Method For Finding Prime Numbers,
    Papyrus 487,
    Library of Alexandria.

Source Code:

Examples and Tests:

You can go up one level to the PYTHON source codes.


Last revised on 26 October 2012.