Catalan numbers: Difference between revisions
Content deleted Content added
Adding non-recursive Maple Example |
Added zkl |
||
Line 2,881: | Line 2,881: | ||
742900 |
742900 |
||
2674440 |
2674440 |
||
</pre> |
|||
=={{header|zkl}}== |
|||
Uses GMP to calculate big factorials. |
|||
<lang zkl>var BN=Import("zklBigNum"); |
|||
fcn catalan(n){ |
|||
BN(2*n).factorial() / BN(n+1).factorial() / BN(n).factorial(); |
|||
} |
|||
foreach n in (16){ |
|||
println("%2d --> %,d".fmt(n, catalan(n))); |
|||
} |
|||
println("%2d --> %,d".fmt(100, catalan(100)));</lang> |
|||
{{out}} |
|||
<pre> |
|||
0 --> 1 |
|||
1 --> 1 |
|||
2 --> 2 |
|||
3 --> 5 |
|||
4 --> 14 |
|||
5 --> 42 |
|||
6 --> 132 |
|||
7 --> 429 |
|||
8 --> 1,430 |
|||
9 --> 4,862 |
|||
10 --> 16,796 |
|||
11 --> 58,786 |
|||
12 --> 208,012 |
|||
13 --> 742,900 |
|||
14 --> 2,674,440 |
|||
15 --> 9,694,845 |
|||
100 --> 896,519,947,090,131,496,687,170,070,074,100,632,420,837,521,538,745,909,320 |
|||
</pre> |
</pre> |