catalan: Catalan Numbers

View source: R/fibonacci.R

catalanR Documentation

Catalan Numbers

Description

Generate Catalan numbers.

Usage

catalan(n)

Arguments

n

integer, asking for the n-th Catalan number.

Details

Catalan numbers, commonly denoted as C_n, are defined as

C_n = \frac{1}{n+1} {2 n \choose n}

and occur regularly in all kinds of enumeration problems.

Value

A single integer, as long as n<=30.

Examples

C <- numeric(10)
for (i in 1:10) C[i] <- catalan(i)
C[5]                                #=> 42

numbers documentation built on Nov. 23, 2022, 9:06 a.m.