#include "primes.h" int next_prime_after(int prime); int main(void){ int numPrimes, i, prime; printf("V3: Primes will be printed\n"); printf("----------------------\n\n"); printf("How many do you want to see? "); scanf("%d",&numPrimes); for(i = 1, prime = 2; i <= numPrimes; i++, prime = next_prime_after(prime)) printf("%6d: %10d\n", i, prime); return 0; } /* Given that prime is a prime number return the smallest prime which is larger than prime */ int next_prime_after(int prime){ int candidate = (prime == 2)? 3 : prime + 2; while (!is_prime(candidate)) candidate += 2; return candidate; }