Created
February 20, 2017 14:45
-
-
Save cls/4cb616f6c639bc878051bd402ae4a0d5 to your computer and use it in GitHub Desktop.
Calculating the Catalan number series
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
from fractions import Fraction | |
def catalan(n): | |
c = 1 | |
for k in range(2, n + 1): | |
c *= Fraction(n + k, k) | |
return int(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment