Skip to content

Commit 44d2b33

Browse files
authored
Update TwinPrime.js
1 parent 2f82828 commit 44d2b33

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Maths/TwinPrime.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ function isPrime (n) {
1313
return !prime
1414
}
1515

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+
*/
1624
function twinPrime (n) {
1725
const result = []
1826
const prime = isPrime(n)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy