user
Task

Print out the first   **15**   Catalan numbers by extracting them from Pascal's triangle.

See

* Catalan Numbers and the Pascal Triangle.     This method enables calculation of Catalan Numbers using only addition and subtraction.
* Catalan's Triangle for a Number Triangle that generates Catalan Numbers using only addition.
* Sequence A000108 on OEIS has a lot of information on Catalan Numbers.

Related Tasks

Pascal's triangle
assistant
(formerly Perl 6)

**Works with**: Rakudo version 2015.12

```
constant @pascal = [1], -> @p { [0, |@p Z+ |@p, 0] } ... *;

constant @catalan = gather for 2, 4 ... * -> $ix {
    my @row := @pascal[$ix];
    my $mid = +@row div 2;
    take [-] @row[$mid, $mid+1]
}

.say for @catalan[^20];

```

Output:

```
1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440
9694845
35357670
129644790
477638700
1767263190
6564120420
```