From 328f13c1b2ec63826bd389a72f459775362c53bf Mon Sep 17 00:00:00 2001 From: Christian Bender Date: Fri, 23 Mar 2018 21:08:21 +0100 Subject: [PATCH] fixed and improved Prime.c --- misc/Prime.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/misc/Prime.c b/misc/Prime.c index a591e255..c98284bc 100644 --- a/misc/Prime.c +++ b/misc/Prime.c @@ -1,16 +1,13 @@ #include +#include int isPrime(int x) { - if (x == 1) - return 0; - if (x % 2 == 0) - return 0; - for (int i = 3; i < x; i++) { // May replace x with sqrt(x) + for (int i = 2; i < sqrt(x); i++) { if (x%i == 0) return 0; } return 1; - + } int main() {