21 lines
362 B
Text
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
|