Improve code
This commit is contained in:
6
C/p051.c
6
C/p051.c
@ -30,7 +30,11 @@ int main(int argc, char **argv)
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
|
||||
/* N set to 1000000 as a reasonable limit, which turns out to be enough.*/
|
||||
primes = sieve(N);
|
||||
if((primes = sieve(N)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error! Sieve function returned NULL\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Checking only odd numbers with at least 4 digits.*/
|
||||
for(i = 1001; i < N; i += 2)
|
||||
|
6
C/p060.c
6
C/p060.c
@ -24,7 +24,11 @@ int main(int argc, char **argv)
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &start);
|
||||
|
||||
primes = sieve(N);
|
||||
if((primes = sieve(N)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Error! Sieve function returned NULL\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Straightforward brute force approach.*/
|
||||
for(p1 = 3; p1 < N && !found; p1 += 2)
|
||||
|
Reference in New Issue
Block a user