Catalan numbers/Pascal's triangle: Difference between revisions

Content added Content deleted
(RPL: add section)
(add RPL - fast, idiomatic)
Line 2,022: Line 2,022:
1: { 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845 }
1: { 1 2 5 14 42 132 429 1430 4862 16796 58786 208012 742900 2674440 9694845 }
</pre>
</pre>
Runs in 119 seconds on a HP-28S.
Runs in 119 seconds on an 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}}==
=={{header|Ruby}}==