Created
April 19, 2015 20:22
-
-
Save sheniff/4a1d2d9a2d31b9d56ddd to your computer and use it in GitHub Desktop.
Catalan Numbers to mathematically verify number of combinations (http://en.wikipedia.org/wiki/Catalan_number)
This file contains hidden or 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
| // Catalan Numbers to mathematically verify number of combinations | |
| // E.g, the number of possible combinations of parentheses | |
| // http://en.wikipedia.org/wiki/Catalan_number | |
| function catalanNumber(numParens) { | |
| var total = 1; | |
| for(var i = 2; i <= numParens; i++) { | |
| total *= (numParens + i) / i; | |
| } | |
| return total; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment