Created
November 30, 2020 23:48
-
-
Save gavinsykes/dd233ca59352f9f950a0f19af9fc70b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const euler_15 = n => nCr(2*n,n); | |
const nCr = (n,r) => { | |
if (r > n || n < 1 || r < 1) { | |
return undefined; | |
} | |
return factorial(n) / (factorial(r) * factorial(n-r)); | |
}; | |
const factorial = num => { | |
let result = 1, | |
n = +num; | |
while (n > 1) { | |
n--; | |
result *= n; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment