PRIME
Sum of Prime Numbers from 2 to N


PRIME is a program which computes the sum of all prime numbers from 2 up to a user-specified limit N.

The program has a loop variable I, which runs from 2 to N. Each I is checked for primality by dividing it by every possible factor J less than I. If no factor is found, the value of I is added to the total.

This program is interesting because it is clear that the amount of work for each loop iteration increases with I. Thus, if the work is to be divided among "equally" among processors, some care should be taken.

The program is currently set with N equal to 100,000, which results in a prime sum of 454,396,537.

Source Code:


You can go up one level to the FDI 2008 web page.

Last revised on 29 May 2008.