Tutorial by Examples

Catalan numbers algorithm is Dynamic Programming algorithm. In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. The Catalan numbers on nonnegative integers n are a set of numbers t...
public class CatalanNumber { public static int Main(int number) { int result = 0; if (number <= 1) return 1; for (int i = 0; i < number; i++) { result += Main(i)*Main(number - i - 1); } return result; } }

Page 1 of 1