0
In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They are named after the Belgian mathematician Eugùne CharlesCatalan (1814–1894). Code: static void Main(string[] args) { int i, n, fact, fact1, fact2, CatalanN; Console.WriteLine("Enter a Number (n>=0)"); n = Convert.ToInt32(Console.ReadLine()); fact = n; for (i = n - 1; i > 0; i--) { fact = fact * i; } Console.WriteLine("" + fact); Console.ReadLine(); fact1 = 2*n; for (i = 2*n - 1; i > 0; i--) { int old = fact1; fact1 = fact1 * i; Console.WriteLine("" + old + " " + fact1); } Console.ReadLine(); fact2 = n+1; for (i = (n+1)-1; i > 0; i--) { fact2 = fact2 * i; } Console.WriteLine("" + fact2); Console.ReadLine(); CatalanN = fact1 / (fact2 * fact); Console.WriteLine("Catalan Number of the given number is : " + CatalanN); Console.ReadLine(); }
16th Dec 2017, 1:34 PM
Bits!