RosettaCodeData/Task/Least-common-multiple/Factor/least-common-multiple-2.factor

13 lines
189 B
Factor
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
USING: kernel math prettyprint ;
IN: script
: gcd ( a b -- c )
[ abs ] [
[ nip ] [ mod ] 2bi gcd
] if-zero ;
: lcm ( a b -- c )
[ * abs ] [ gcd ] 2bi / ;
26 28 lcm .