Skip to content

Commit 891a155

Browse files
checkForPrime Q&A aaded
1 parent d5afa8d commit 891a155

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

must-do-questions/checkForPrime.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,17 @@ O(1), i.e., constant space complexity.
2323
Constraints
2424
1 <= N <= 1000000000*/
2525

26-
26+
function Solution(n) {
27+
let factor = 0;
28+
for (let i = 1; i <= n; i++) {
29+
if (n % i === 0) {
30+
factor++;
31+
}
32+
}
33+
if (factor === 2) {
34+
console.log("Yes");
35+
} else {
36+
console.log("No");
37+
}
38+
}
39+
Solution(4);

0 commit comments

Comments
 (0)