RosettaCodeData/Task/Least-common-multiple/Forth/least-common-multiple.fth
2023-07-01 13:44:08 -04:00

6 lines
142 B
Forth

: gcd ( a b -- n )
begin dup while tuck mod repeat drop ;
: lcm ( a b -- n )
over 0= over 0= or if 2drop 0 exit then
2dup gcd abs */ ;