From d8d121930fccd5452c0f850405294573b370d2e7 Mon Sep 17 00:00:00 2001 From: Hector Remedios Date: Fri, 17 Jul 2020 17:47:10 -0500 Subject: [PATCH] This is a fix in the algorithm to detect the prime numbers --- src/index.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 4c197d6..e39e2e6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,19 @@ -const trialDivision = (number) => { - +const trialDivision = (num) => { + var quantity = 0; + var i = num; + + while (i > 0){ + if (num % i === 0){ + quantity++; + } + i--; + } + + if (quantity === 2){ + return true; + }else{ + return false; + } } - module.exports = trialDivision; \ No newline at end of file + module.exports = trialDivision;