/*-*-mode:c-*-
***************************************************************************
CSN381: Project 2, problem 3
http://homepage.mac.com/hteric/Project2.pdf
***************************************************************************
File : gcd.c
Author : Jeremy Russell
Date : September 23, 2002
Description : Project 2, 3b
***************************************************************************/
#include <stdio.h>
#define TOP 1000
void removeMultiples ( int, int *);
int main ( void )
{
// Set 0 and 1 to false and the rest to tru until
// they are proven to not be prime.
int primes[TOP];
int i;
// Initialize the array.
primes[0] = 0;
primes[1] = 0;
for (i = 2; i <= TOP; i++)
{
primes[i] = 1;
}
for (i = 0; i <= TOP; i++)
{
if (primes[i])
{
removeMultiples(i, primes);
printf("%d\n", i);
}
}
return 0;
}
/***************************************************************************
Function : ckprime
Author : Jeremy Russell
Date : September 23, 2002
Description : Set to false all multiple of the number.
Arguments : int num, int *prime, int primeLen
Returns : voiod
Notes : None
See Also : None
***************************************************************************/
void removeMultiples ( int number, int *list)
{
int j;
for (j = number; j <= TOP; j += number)
{
list[j] = 0;
}
}