# Catalan numbers

The recursive formulas are easily written into a constant array, either:

```perl
constant Catalan = 1, { [+] @_ Z* @_.reverse } ... *;
```

or

```perl
constant Catalan = 1, |[\*] (2, 6 ... *) Z/ 2 .. *;


# In both cases, the sixteen first values can be seen with:
.say for Catalan[^16];
```

#### Output:

```
1
1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/perl6-rosettacode/programming_tasks/c/catalan_numbers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
