From e9ebef8951fc20a9bf49ea816b912a85b62129fd Mon Sep 17 00:00:00 2001 From: Bernardo Waldhelm Date: Fri, 28 Oct 2022 13:46:14 -0300 Subject: [PATCH] feat(isPrime): adicionando resolucao desafio 5 isPrime --- 05-isPrime/index.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..6f72492 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,22 @@ export function isPrime(value) { // implementar logica aqui - + let totalDivisores = 0; + + for (let i = 1; i <= value; i++) { + if (value % i == 0) { + totalDivisores++ + } + } + + if (totalDivisores == 2) { + return true; + } else return false + + if (value === 2) { + return true; + } + + if (value === 1) { + return false; + } } \ No newline at end of file