retroforth/example/LeastCommonMultiple.forth
crc 183c5bae38 Initial checkin (from 58fa921 in the old git repo)
FossilOrigin-Name: d2b8467883db80cb179089e1db1b1ed4dff1f11b4bee7086ee46d83f3ee0136e
2017-10-16 16:09:39 +00:00

17 lines
242 B
Forth

# example|LeastCommonMultiple
Declare module constant (prevents reloading when using `import`):
````
:example|LeastCommonMultiple ;
````
----
````
:gcd (ab-n)
[ tuck mod dup ] while drop ;
:lcm (ab-n)
dup-pair gcd [ * ] dip / ;
````