prime, a Python code 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.
The information on this web page is distributed under the MIT license.
prime is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.
fire_serial, a Python code 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.
is_prime, a Python code which determines if a given integer n is prime, using various versions of the sieve of Eratosthenes.
lucas_lehmer, a Python code which determines whether a Mersenne number 2^n-1 is prime by applying the Lucas-Lehmer test.
prime_factors, a Python code which returns a list of the prime factors of an integer.
prime_fermat, a Python code which applies Fermat's primality test to an integer n, which always correctly identifies primes, but sometimes also accepts nonprimes. Nonetheless, the test is useful for weeding out most nonprimes. The accuracy of the test can be improved by running it for several bases.
prime_pi, a Python code which evaluates Pi(n), the number of primes less than or equal to an integer n.
prime_plot, a Python code which displays a box plot of the prime and composite numbers.
quad_serial, a Python code which approximates an integral using a quadrature rule, and is intended as a starting point for parallelization exercises.
search_serial, a Python code 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.