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 2f82828 commit 44d2b33Copy full SHA for 44d2b33
Maths/TwinPrime.js
@@ -13,6 +13,14 @@ function isPrime (n) {
13
return !prime
14
}
15
16
+/**
17
+ * @function twinPrime
18
+ * Gets the 'twin prime' of a prime number.
19
+ * @returns {Array} Either an array with the original [0], and the twin [1], or an empty array if one of the numbers are not prime.
20
+ * @see https://en.wikipedia.org/wiki/Twin_prime
21
+ * @example twinPrime(5) = [5, 7]
22
+ * @example twinPrime(4) = []
23
+*/
24
function twinPrime (n) {
25
const result = []
26
const prime = isPrime(n)
0 commit comments