Name: Anonymous 2007-09-14 9:02 ID:w+iUxD20
: n! ( n -- n! ) dup zero? [ drop 1 ] [ dup 1- n! * ] if ;
: ln! ( n lim -- ) over - [ dup n! . 1+ ] times drop ;
1 10 ln!
1
2
6
24
120
720
5040
40320
362880Superior.
: n! ( n -- n! ) dup zero? [ drop 1 ] [ dup 1- n! * ] if ;
: ln! ( n lim -- ) over - [ dup n! . 1+ ] times drop ;
1 10 ln!
1
2
6
24
120
720
5040
40320
362880[define [fact n]
[define [fact-iter a n]
[if [= n 1]
a
[fact-iter [* a n] [- n 1]]]]
[fact-iter 1 n]]