Jump to content

Catalan numbers/Pascal's triangle: Difference between revisions

Added Common Lisp
(Added 11l)
(Added Common Lisp)
Line 389:
1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, 208012, 742900, 2674440, 9694845
</pre>
 
 
=={{header|Common Lisp}}==
 
<lang Lisp>(defun catalan (n)
"Return the n-th Catalan number"
(if (<= n 1) 1
(let ((result 2))
(dotimes (k (- n 2) result)
(setq result (* result (/ (+ n k 2) (+ k 2)))) ))))
 
 
(dotimes (n 15)
(print (catalan (1+ n))) )</lang>
 
{{out}}
 
<pre>1
2
5
14
42
132
429
1430
4862
16796
58786
208012
742900
2674440
9694845</pre>
 
 
=={{header|D}}==
47

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.