Skip to content

Commit 2ee446c

Browse files
committed
prime number would be positive
1 parent 49fffc3 commit 2ee446c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

primeNum.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@
2121
// So, we've got that 33 is not a prime number.
2222

2323
// Now let's write this in code:
24+
// (N.B. given num/integer must be positive. That's why i>1)
2425
const primeNum = (num) => {
2526
const limit = Math.ceil(Math.sqrt(num));
26-
for (i = 2; i <= limit; i++) {
27+
for (i = 2; i > 1 && i <= limit; i++) {
2728
if (num % i === 0) {
2829
return false;
2930
}

0 commit comments

Comments
 (0)