Skip to content

Instantly share code, notes, and snippets.

@JacobLinCool
Created August 12, 2020 15:50
Show Gist options
  • Save JacobLinCool/27e8e016462c8cbf6fa1f6e72ca593b9 to your computer and use it in GitHub Desktop.
Save JacobLinCool/27e8e016462c8cbf6fa1f6e72ca593b9 to your computer and use it in GitHub Desktop.
// Factorial
function F(n){
let sum = 1;
for(let i = 1; i <= n; i++) sum *= i;
return sum;
}
// Permutation
function P(a, b) {
return (F(a) / F(a-b));
}
// Combination
function C(a, b) {
return (P(a, b) / F(b));
}
// H
function H(a, b) {
return C(a+b-1, b);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment