Post Reply 
(49g 50g) Fast Pascal's triangle and its relatives
08-20-2018, 12:43 AM
Post: #5
RE: (49g 50g) Fast Pascal's triangle and its relatives
(08-19-2018 02:14 PM)John Keith Wrote:  By definition, each entry in Pascal's triangle is the sum of the two numbers above it. This leads to a very fast method of computing a row of Pascal's triangle given the previous row (as a list) on the stack:

Code:

\<< 2.
  \<< +
  \>> DOSUBS 1 SWAP + 1 +
\>>

Smaller but a tad slower (just thinking of alternative methods for fun):

Code:
\<< 0 + LASTARG SWAP + ADD \>>

<0|ΙΈ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (49g 50g) Fast Pascal's triangle and its relatives - Joe Horn - 08-20-2018 12:43 AM



User(s) browsing this thread: 1 Guest(s)