Lab 3: Arrays

The goal of this lab is to practice creating and using basic arrays. This reading gives you a chance to think about the problem before you come to class. Note that you do need to indicate (at the bottom of this page) that you have done the reading.

The Sieve of Eratosthenes

The Sieve of Eratosthenes is a method for finding prime numbers. The idea is first to write out all numbers (from 2 up to a certain highest number) in a list.

Then cross off all the multiples of 2.

The next uncrossed number (in this case 3) is also the next prime number. Cross off every 3rd number that's not already crossed off.

Repeat this process. Find the next uncrossed number (say, n) and cross off every nth number after that.

Your task will be to write a program that uses this technique to compute all the prime numbers less than 100.

Things to think about:

I, read the pre-lab

Thomas VanDrunen and Cary Gray
Last modified: Fri Jan 31 11:12:28 CST 2014