There was an error while loading. Please reload this page.
1 parent 49fffc3 commit 2ee446cCopy full SHA for 2ee446c
primeNum.js
@@ -21,9 +21,10 @@
21
// So, we've got that 33 is not a prime number.
22
23
// Now let's write this in code:
24
+// (N.B. given num/integer must be positive. That's why i>1)
25
const primeNum = (num) => {
26
const limit = Math.ceil(Math.sqrt(num));
-for (i = 2; i <= limit; i++) {
27
+for (i = 2; i > 1 && i <= limit; i++) {
28
if (num % i === 0) {
29
return false;
30
}
0 commit comments