From b3864e812b26ccaf1ec2ea5e47615a95b2e4e051 Mon Sep 17 00:00:00 2001 From: Emmanuel Vitor Date: Mon, 31 Oct 2022 13:37:47 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20cria=20algoritmo=20que=20retorne=20se?= =?UTF-8?q?=20o=20numero=20passado=20=C3=A9=20primo=20ou=20n=C3=A3o.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05-isPrime/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..bebebf8 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,11 @@ export function isPrime(value) { // implementar logica aqui - + + let numberOfDivisors = 0 + for (let i = 1; i <= value; i++) { + if ((value % i) === 0) { + numberOfDivisors++; + } + } + return (numberOfDivisors === 2) ? true : false } \ No newline at end of file