From b414bff9dc8c916ccc018acd6a14b0a87454bb4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Wed, 14 Dec 2016 15:55:39 +0100 Subject: [PATCH] Minor optimization. --- src/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 2e622b8..4dbf6fc 100644 --- a/src/main.c +++ b/src/main.c @@ -42,8 +42,7 @@ int main(void) { // Calculate half of `num' mpz_fdiv_q_ui(halfNum, num, 2); // Loop through found primes - for(size_t i = 0; i < primes.end; ++i) { - if(mpz_cmp(primes.list[i], halfNum) > 0) break; + for(size_t i = 0; mpz_cmp(primes.list[i], halfNum) < 0; ++i) { // If `num' is divisible by a prime then go to the next number if(mpz_divisible_p(num, primes.list[i]) != 0) goto nextPrime;