From e9035b4a532a09ad0f02a2ec7a3c7bb2a32e27f7 Mon Sep 17 00:00:00 2001 From: ThiagoDuutra Date: Fri, 28 Oct 2022 16:55:14 -0300 Subject: [PATCH] feat: Resolvido questao isPrime --- 05-isPrime/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/05-isPrime/index.js b/05-isPrime/index.js index ec9c4ac..8d664e1 100644 --- a/05-isPrime/index.js +++ b/05-isPrime/index.js @@ -1,4 +1,15 @@ export function isPrime(value) { // implementar logica aqui - -} \ No newline at end of file + let cont = 0; + for (let i = 1; i <= value; i++) { + if (value % i === 0) { + cont++; + } + } + if (cont === 2) { + // Se conseguiu fazer a divisão apenas por dois números + return true; + } else { + return false; + } +} -- 2.34.1