Created
July 10, 2019 16:41
-
-
Save tspringborg/309e27672e2f4fd8b3b44e4db8b718c3 to your computer and use it in GitHub Desktop.
javascript binomial cooefficient
This file contains 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
function binomial(n, k) { | |
if ((typeof n !== 'number') || (typeof k !== 'number')) | |
return false | |
let coeff = 1 | |
for (var x = n-k+1; x <= n; x++) coeff *= x | |
for (x = 1; x <= k; x++) coeff /= x | |
return coeff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment