//===================================================== file = prime1.c ===== //= Program to find the first N prime numbers = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() and feof() #include // Needed for atoi() #include // Needed for pow() //===== Main program ======================================================== void main(int argc, char *argv[]) { unsigned int i, count, test_val, max, N; N = atoi(argv[1]); test_val = 3; count = 2; while(1) { top: test_val = test_val + 2; max = sqrt((double) test_val) + 1; for (i=3; i<=max; i=i+2) if ((test_val % i) == 0) goto top; count++; if (count == N) break; } printf("The %dth prime number is %d \n", N, test_val); }