Anonymous user
Catalan numbers: Difference between revisions
Updated to work with Nim 1.4. Removed "binomial" procedure to use the "binom" proc of module "math"? Use now "strformat" for formatting.
(add tinybasic) |
(Updated to work with Nim 1.4. Removed "binomial" procedure to use the "binom" proc of module "math"? Use now "strformat" for formatting.) |
||
Line 2,977:
=={{header|Nim}}==
<lang nim>import
import strformat
proc
▲ binomial(2 * n, n) div (n + 1)
▲proc catalan2(n): auto =
if n == 0:
for i in 0
result += catalan2(i) * catalan2(n - 1 - i)
proc catalan3(n: int): int =
if n > 0: 2 * (2 * n - 1) * catalan3(n - 1) div (1 + n)
else: 1
for i in 0..15:
echo
{{out}}
<pre> 0 1 1 1
1 1 1 1
|