Website Summary Files Commits Branches @commit @diff @stats
path: root / Week05 / Exercise21.cpp
blob: 15723722031cf54f429ad692df1e613ad80efc2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <iostream>

int main() {
    unsigned int n;
    std::cin >> n;

    unsigned long f1 = 1, f2 = 1, f3 = 1;
    for (unsigned long i = 1; i <= 2 * n; i++) {
        f1 *= i;
        if (i <= n + 1)
            f2 *= i;
        if (i <= n)
            f3 *= i;
    }

    unsigned long catalan = f1 / (f2 * f3);

    std::cout << catalan << std::endl;

    return 0;
}