diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 09:58:51 +0200 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2022-11-07 12:50:34 +0200 |
commit | cdb159c137a82fd9756300dd6d1cba68f509b606 (patch) | |
tree | 38a2a3aeaff826ca06d2655c0c7772076b10a662 | |
parent | 2d27a4fbe3d9c8386c5477ac67a129ecba2c3ec7 (diff) | |
download | gcd-cdb159c137a82fd9756300dd6d1cba68f509b606.tar.gz |
lisp: no recursion
-rw-r--r-- | gcd.lisp | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -5,9 +5,9 @@ ; # sbcl --script gcd.lisp 121 22 33 (defun gcd2 (a b) - (if (= b 0) - a - (gcd2 b (mod a b)))) + (loop while (/= b 0) do + (psetq a b b (mod a b)) + finally (return a))) (defun gcdn (n &rest ns) (reduce #'gcd2 ns :initial-value n)) |