Catalan numbers: Difference between revisions

Add CLU
m (→‎{{header|Lambdatalk}}: adding a vertical display)
(Add CLU)
Line 1,336:
user> (take 15 (catalan-numbers-recursive))
(1 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440)</syntaxhighlight>
=={{header|CLU}}==
<syntaxhighlight lang="clu">catalan = iter (amount: int) yields (int)
c: int := 1
for n: int in int$from_to(1, amount) do
yield(c)
c := (4*n-2)*c/(n+1)
end
end catalan
 
start_up = proc ()
po: stream := stream$primary_output()
for n: int in catalan(15) do
stream$putl(po, int$unparse(n))
end
end start_up</syntaxhighlight>
{{out}}
<pre>1
1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440</pre>
 
=={{header|Common Lisp}}==
With all three methods defined.
Line 1,366 ⟶ 1,398:
(format t "~%Method ~d:~%" i)
(dotimes (i 16) (format t "C(~2d) = ~d~%" i (funcall f i))))</syntaxhighlight>
 
=={{header|Crystal}}==
{{trans|Ruby}}
2,125

edits