CS4HS Summer Program for HS Teachers

July 2011

Problem 2

Sum of primes

Definition (from Wikipedia):

A natural number is called a prime number (or a prime) if it is bigger than one and has no divisors other than 1 and itself. For example, 5 is prime, since no number except 1 and 5 divides it. On the other hand, 6 is not a prime (it is composite), since 6 = 2 * 3.

The input file **DATA2.txt** will contain 5 lines, each line having an integer N with 5 <= N <= 10000.

The output file **OUT2.txt** will contain 5 lines. Each line contains the sum of the primes less than the corresponding **N** in DATA2.txt.

Sample Input (only first 3 shown):

5 10 1000

Sample Output (only first 3 shown):

5 17 76127