1. ## Prime number example

Hi, I'm going through the "Learn C on the Mac" book and getting a bit stuck. I've read through this part of the book countless times now. The exercises at the end of the chapter are modify teh program to computer the prime numbers from 1-100 and another one is to compute the first 100 prime numbers.
Code:
```#include <stdio.h>
#include <stdbool.h>  //This is to bring in the define of true
#include <math.h>  //This is to bring in the define of sqrt()

int main (int argc, const char * argv[]) {
bool    isPrime;
int     startingPoint, candidate, last, i;

startingPoint = 235;

if ( startingPoint < 2 ) {
candidate = 2;
}
else if ( startingPoint == 2 ) {
candidate = 3;
}
else {
candidate = startingPoint;
if (candidate % 2 == 0)             /* Test only odd numbers */
candidate--;
do {
isPrime = true;                 /* Assume glorious success */
candidate += 2;                 /* Bump to the next number to test */
last = sqrt( candidate );       /* We'll check to see if candidate */
/* has any factors, from 3 to last */
/* Loop through odd numbers only */
for ( i = 3; (i <= last) && isPrime; i += 2 ) {
if ( (candidate % i) == 0 )
isPrime = false;
}
} while ( ! isPrime );
}

printf( "The next prime after %d is %d. Happy?\n",
startingPoint, candidate );

return 0;

}```
I understand what's going on in the code, just not sure how to implement those features. I don't really want someone to do it for me, just give me a few pointers.

Thanks.

2. Do you know how to repeat <X> from 1 to 100? Do you know how to do <X> until you have counted to 100? Do you know which of the above code is <X>?

3. A loop like
Code:
```for (i=1;i<=100;i++){
printf("number: %d\n",i);
}```
?
And I take it <X> is...
Code:
```for ( i = 3; (i <= last) && isPrime; i += 2 ) {
if ( (candidate % i) == 0 )
isPrime = false;```
I think, where it's going through all the odd numbers to check if they are prime numbers or not?