RosettaCodeData/Task/Pascals-triangle/8th/pascals-triangle-2.8th
2016-12-05 23:44:36 +01:00

21 lines
362 B
Text

: ratio \ m n -- num denom
tuck n:- n:1+ swap ;
\ one item in the row: n m
: pascitem \ n m -- n
r@ swap
ratio
n:*/ n:round int
dup . space ;
\ One row of Pascal's triangle
: pascline \ n --
>r 1 int dup . space
' pascitem
1 r@ loop rdrop drop cr ;
\ Calculate the first 'n' rows of Pascal's triangle:
: pasc \ n
' pascline 0 rot loop cr ;
15 pasc