We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d04bbba commit 9c9fc1aCopy full SHA for 9c9fc1a
Sprint-3/revise/implement/is-prime.js
@@ -0,0 +1,19 @@
1
+// isPrime.js
2
+function isPrime(num) {
3
+ // If the number is less than 2, it is not prime
4
+ if (num < 2) {
5
+ return false;
6
+ }
7
+
8
+ // Check if the number has divisors (excluding 1 and itself)
9
+ for (let i = 2; i <= Math.sqrt(num); i++) {
10
+ if (num % i === 0) {
11
+ return false; // If a divisor is found, it is not prime
12
13
14
15
+ return true; // If no divisors are found, the number is prime
16
+}
17
18
19
+console.log("All test cases executed!");
0 commit comments