Function: cl-gcd

cl-gcd is an autoloaded and byte-compiled function defined in cl-extra.el.gz.

Signature

(cl-gcd &rest ARGS)

Documentation

Return the greatest common divisor of the arguments.

View in manual

Aliases

gcd (obsolete since 27.1)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-extra.el.gz
;;; Numbers.

;;;###autoload
(defun cl-gcd (&rest args)
  "Return the greatest common divisor of the arguments."
  (let ((a (or (pop args) 0)))
    (dolist (b args)
      (while (/= b 0)
        (setq b (% a (setq a b)))))
    (abs a)))