Learn R Programming

Zseq (version 0.2.0)

Catalan: Catalan numbers

Description

Under OEIS A000108, the nth Catalan number is given as $$C_n = \frac{(2n)!}{(n+1)!n!}$$ where the first 6 entries are 1, 1, 2, 5, 14, 42 with \(n\ge 0.\)

Usage

Catalan(n, gmp = TRUE)

Value

a vector of length n containing first entries from the sequence.

Arguments

n

the number of first n entries from the sequence.

gmp

a logical; TRUE to use large number representation, FALSE otherwise.

Examples

Run this code
## generate first 30 Catalan numbers
print(Catalan(30))

Run the code above in your browser using DataLab