Generates Catalan numbers, a sequence of natural numbers that appear in various combinatorial problems, such as counting binary trees, parenthesizations, and lattice paths.
Make sure you have GHC (Glasgow Haskell Compiler) installed.
cd catalan
ghc catalan.hs -o catalan
./catalan 5 # Linux/macOS
.\catalan.exe 5 # Windows
This program expects one integer argument n
to compute the nth Catalan number.
Example:
./catalan 5 # Linux/macOS
.\catalan.exe 5 # Windows
The program prints Cat(n)
for the input n
.
Example output:
Cat(5) = 42
n
may take longer to compute.n
, consider optimizing or using memoization to improve performance.This project is licensed under the MIT License.