This assignment enters with 3% into the total grade!

Assignment 3

A prime number is a (positive integer) number that is evenly divisible only by 1 and itself.
  1. Write a function isprime() that determines if an integer number is prime. You can use the % (modulus) operator (division rest on integers) or work with plain division. Use your function to implement a program primes_simple that prints all primes between 0 and 10000.
  2. The Sieve of Erathostenes is a more efficient (and ancient) algorithm for finding all primes up to a given number. It starts with a list of all numbers from 2 to the desired limit. It traverses this list, starting at two. Whenever it encounteres a new number, it strikes all multiples of it from the list. What remains at the end is a list of prime numbers.

    Example:

       Initial list:            2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 
       Striking multiples of 2: 2 3   5   7   9    11    13    15
       Striking multiples of 3: 2 3   5   7        11    13
       (There are no multiples of any remainig number, so we skip the rest)
    
    Use the Sieve algorithm in a second program, primes_sieve, that prints all primes between 0 and 10000. Hint: Use an array!

Stephan Schulz,schulz@cs.miami.edu, Thu Aug 22 13:35:31 EDT 2002