Greatest common divisor: Difference between revisions

m
moved to Common Lisp
No edit summary
m (moved to Common Lisp)
Line 772:
until (zerop y)
finally (return x)))</lang>
===Alternate solution===
I use [https://franz.com/downloads/clp/survey Allegro CL 10.1]
 
<lang lisp>
;; Project : Greatest common divisor
;; Date : 2018/03/10
;; Author : Gal Zsolt [~ CalmoSoft ~]
;; Email : <calmosoft@gmail.com>
 
(defun gcds(gcd b)
(loop while (> b 0)
do (setf c gcd)
(setf gcd b)
(setf b (mod c b)))
(write gcd))
(format t "~a" "Greatest common divisor 24 and 32: ")
(gcds 24 32)
</lang>
Output:
<pre>
Greatest common divisor 24 and 32: 8
</pre>
 
=={{header|Component Pascal}}==
Line 1,896 ⟶ 1,918:
}
</lang>
 
=={{header|Lisp}}==
 
I use [https://franz.com/downloads/clp/survey Allegro CL 10.1]
 
<lang lisp>
;; Project : Greatest common divisor
;; Date : 2018/03/10
;; Author : Gal Zsolt [~ CalmoSoft ~]
;; Email : <calmosoft@gmail.com>
 
(defun gcds(gcd b)
(loop while (> b 0)
do (setf c gcd)
(setf gcd b)
(setf b (mod c b)))
(write gcd))
(format t "~a" "Greatest common divisor 24 and 32: ")
(gcds 24 32)
</lang>
Output:
<pre>
Greatest common divisor 24 and 32: 8
</pre>
 
=={{header|LiveCode}}==
1,336

edits