183c5bae38
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
21 lines
284 B
Forth
21 lines
284 B
Forth
# example|RecursiveFactorial
|
|
|
|
Declare module constant (prevents reloading when using `import`):
|
|
|
|
````
|
|
:example|RecursiveFactorial ;
|
|
````
|
|
|
|
----
|
|
|
|
````
|
|
:<factorial>
|
|
dup #1 -eq? 0; drop
|
|
dup n:dec <factorial> * ;
|
|
|
|
:factorial
|
|
dup n:zero?
|
|
[ n:inc ]
|
|
[ <factorial> ] choose ;
|
|
````
|
|
|