Catalan numbers/Pascal's triangle: Difference between revisions

add RPL - fast, idiomatic
(RPL: add section)
(add RPL - fast, idiomatic)
Line 2,022:
1: { 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845 }
</pre>
Runs in 119 seconds on aan HP-28S.
===Fast, idiomatic approach===
Using the built-in <code>COMB</code> function, which returns coefficients of Pascal's triangle:
≪ { } 1 15 '''FOR''' j
j DUP + j COMB LAST 1 - COMB - + '''NEXT'''
≫ EVAL
Same output than above, runs in 2.4 seconds on an HP-28S.
 
=={{header|Ruby}}==
1,150

edits