You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
321 B
22 lines
321 B
2 years ago
|
: fac ( num -- out )
|
||
|
dup 1 > if dup 1- recurse * then ;
|
||
|
|
||
|
: 0bye ( num -- )
|
||
|
0= if bye then ;
|
||
|
|
||
|
: xdrop ( count -- )
|
||
|
0 do drop loop ;
|
||
|
|
||
|
: >single ( c-addr u1 -- u2 )
|
||
|
0 0 2swap >number 3 xdrop ;
|
||
|
|
||
|
30 chars buffer: buf
|
||
|
|
||
|
." Number: "
|
||
|
buf 30 accept dup 0bye
|
||
|
buf swap >single
|
||
|
|
||
|
." Factorial of " dup . ." is "
|
||
|
|
||
|
fac . cr
|