August 19, 2024

P32 - Determine the greatest common divisor of two positive integer numbers

Use Euclid's algorithm.

Example:* (gcd 36 63)9

lisp

;;;  Retorna o maximo divisor comum
(defun my-gcd (m n)
(if (= n 0)
m
(my-gcd n (mod m n))
)
)
Be first to comment
Leave a reply