Skip to content

Instantly share code, notes, and snippets.

@gavinsykes
Created November 30, 2020 23:48
Show Gist options
  • Save gavinsykes/dd233ca59352f9f950a0f19af9fc70b6 to your computer and use it in GitHub Desktop.
Save gavinsykes/dd233ca59352f9f950a0f19af9fc70b6 to your computer and use it in GitHub Desktop.
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