RosettaCodeData/Task/Least-common-multiple/Common-Lisp/least-common-multiple-2.lisp
2023-07-01 13:44:08 -04:00

10 lines
234 B
Common Lisp

CL-USER> (defun my-lcm (&rest args)
(reduce (lambda (m n)
(cond ((or (= m 0) (= n 0)) 0)
(t (abs (/ (* m n) (gcd m n))))))
args :initial-value 1))
MY-LCM
CL-USER> (my-lcm 12 18)
36
CL-USER> (my-lcm 12 18 22)
396