if k > n - k:
    k = n - k
for i in range(k):
    res *= n - i
res //= i + 1
return res

def CatalanNumbers(n):
    c = BinominalCoefficient(2 * n, n)
return c // (n + 1)
print(CatalanNumbers(511))
Python calculating Catalan Numbers