From 06d5ddb0cc71d7ee00dfe2d42c3211bccd927b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Tue, 13 Dec 2016 18:05:02 +0100 Subject: [PATCH] Fixed problem with the algorithm. If it's equal to half then we want to check if it's divisible, since if it's half then it is NOT prime. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 7689138..3cd14e6 100644 --- a/src/main.c +++ b/src/main.c @@ -44,7 +44,7 @@ int main(void) { mpz_fdiv_q_ui(halfNum, num, 2); // Loop through found primes for(ulli i = 0; i < primes.end; ++i) { - if(mpz_cmp(primes.list[i], halfNum) >= 0) break; + if(mpz_cmp(primes.list[i], halfNum) > 0) break; // If `num' is divisible by a prime then go to the next number if(mpz_divisible_p(num, primes.list[i]) != 0) goto nextPrime;