Catalan numbers: Difference between revisions

 
(6 intermediate revisions by 4 users not shown)
Line 2,310:
=={{header|EasyLang}}==
<syntaxhighlight lang="text">
procfunc catalan n . ans .
if n = 0
ans = return 1
else .
return call2 * (2 * n - 1) * catalan (n - 1) hdiv (1 + n)
ans = 2 * (2 * n - 1) * h div (1 + n)
.
.
for i = 0 to 14
call print catalan i h
print h
.
</syntaxhighlight>
{{out}}
<pre>
1
1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440
</pre>
 
=={{header|EchoLisp}}==
Line 3,799 ⟶ 3,778:
=={{header|langur}}==
{{trans|Perl}}
<syntaxhighlight lang="langur">val .factorial = ffn(.x) { if(.x < 2: 1; .x x self(.x - 1)) }
 
val .catalan = ffn(.n) { .factorial(2 x .n) / .factorial(.n+1) / .factorial(.n) }
 
for .i in 0..15 {
Line 6,190 ⟶ 6,170:
{{libheader|Wren-fmt}}
{{libheader|Wren-math}}
<syntaxhighlight lang="ecmascriptwren">import "./fmt" for Fmt
import "./math" for Int
var catalan = Fn.new { |n|
Line 6,253 ⟶ 6,233:
15 9694845
</pre>
 
=={{header|XLISP}}==
<syntaxhighlight lang="lisp">(defun catalan (n)
885

edits