We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents f514b33 + 3ae7080 commit a31c1a0Copy full SHA for a31c1a0
2 files changed
prime-number/README.md
@@ -0,0 +1,7 @@
1
+# Prime number
2
+
3
+Determine if a number is prime or not. As an output provide boolean
4
5
+Sample:
6
+Input function: `isPrime(13)`
7
+Output: `true`
prime-number/isPrime.js
@@ -0,0 +1,8 @@
+const isPrime = (n) => {
+ for (let i = 2; i < n; i++) if (n % i === 0) return false
+ return n !== 1
+}
+console.log(isPrime(12))
+console.log(isPrime(13))
8
+console.log(isPrime(11))
0 commit comments