Last active
August 29, 2015 14:27
-
-
Save vdonchev/5b1eb89970f02ad16951 to your computer and use it in GitHub Desktop.
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
Console.Write("Enter number between 1 and 100 (n):"); | |
int n = int.Parse(Console.ReadLine()); | |
if (1 < n && n < 100) | |
{ | |
BigInteger doubleN = 1; | |
BigInteger nPlus = 1; | |
BigInteger num = 1; | |
for (int i = 2; i <= n * 2; i++) | |
{ | |
doubleN *= i; | |
if (i <= n + 1) | |
{ | |
nPlus *= i; | |
} | |
if (i <= n) | |
{ | |
num *= i; | |
} | |
} | |
BigInteger result = doubleN / (nPlus * num); | |
Console.WriteLine("Catalan(n) = " + result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment