Last active
October 16, 2017 02:25
-
-
Save nektro/fa8027f5ae189d4ced9afb7611cc5c40 to your computer and use it in GitHub Desktop.
algorithm 3.2
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 bin2(n, k) | |
{ | |
const B = new Array(n+1).fill(0).map((x) => { | |
return new Array(k+1).fill(0); | |
}); | |
for (let i = 0; i <= n; i++) { | |
for (let j = 0; j <= Math.min(i,k); j++) { | |
if (j === 0 || j === i) { | |
B[i][j] = 1; | |
} | |
else { | |
B[i][j] = B[i-1][j-1] + B[i-1][j]; | |
} | |
} | |
} | |
return B[n][k]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment