/*
I figured I'd describe the code here, since I didn't write it.
Since I failed the lesson, I'll at least explain it. To continue on
then!
*/
#include <stdio.h>
//#include <stdlib.h> is not needed, don't know why you put it there.
#define FIRST 2 // Obvious
#define LAST 1000 // Read previous comment.
char prime[1001] = {0}; /* Dont' understand "{0}", errors without it.
Either way, declare array "prime" with 1001
elements, with the last element declared NULL
*/
main(void)
{
unsigned long d=0; // I know unsigned means 16 or 32 bits,
unsigned long x=0; // and long means 32..But why use it?
printf("Beginning\!\n");
for (x = FIRST; x <= LAST; x++) // Obvious
{
for (d=2; d<x; d++) // Read above comment
{
// if x%d = 0, prime[x] = 1
// kinda stoned, may have mixed up 0/1
if (!(x % d)) prime[x] = 1;
}
}
for (x = FIRST; x <= LAST; x++)
{
// if prime[x] = 0 print element x
if (!prime[x]) printf("%i\n",x);
}
return 0;
}