All pastes #282826 Raw Edit

Something

public text v1 · immutable
#282826 ·published 2006-12-17 22:04 UTC
rendered paste body
/*
   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. //I just put it there out of habit... I usually need something or other later

#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
			*/
/* {0} means fill the array with 0's: 000000000000. {0,1,2,3} would fill it in a pattern: 0123012301230123... */

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? 
//unsigned means that it can only be positive. This makes no difference on how data is stored, but it lets the compiler know that I don't need negative numbers. example: 8-bit signed goes from -128 to +127. 8-bit unsigned would be 0 to 255. The H.O. bit makes it negative in signed mode.
//long is 32, but we use it for maximum capacity. It gives us a high max value, so we can run really high benchmarks later. the max value is 2^32 for a long.

	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
                        // yeah, it's pretty much if it equals 0 .
			// 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;
}