Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tspringborg/309e27672e2f4fd8b3b44e4db8b718c3 to your computer and use it in GitHub Desktop.
Save tspringborg/309e27672e2f4fd8b3b44e4db8b718c3 to your computer and use it in GitHub Desktop.
javascript binomial cooefficient
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