From 62d6622332a0b39d7f6f4cb7fda3ba54fc244c78 Mon Sep 17 00:00:00 2001 From: amanda almeida Date: Fri, 28 Oct 2022 15:28:45 -0300 Subject: [PATCH] =?UTF-8?q?feat(isPrime):=20Adiciona=20a=20logica=20do=20a?= =?UTF-8?q?lgoritmo=20que=20retorna=20se=20o=20numero=20passado=20=C3=A9?= =?UTF-8?q?=20primo=20ou=20n=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 05-isPrime/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..1b63e08 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,14 @@ export function isPrime(value) { // implementar logica aqui - + let Prime = true; + for (let i = 2; i < value; i++) { + if (value % i === 0) { + Prime = false; + break; + } + } + if (Prime === true && value === 1) { + Prime = false; + } + return Prime; } \ No newline at end of file