Greatest common divisor: Difference between revisions

Content added Content deleted
(add JavaScript)
Line 878: Line 878:
=={{header|Scheme}}==
=={{header|Scheme}}==
<lang scheme>(define (gcd a b)
<lang scheme>(define (gcd a b)
(cond ((= a 0) b)
(if (= b 0)
((= b 0) a)
a
((> a b) (gcd b (modulo a b)))
(gcd b (modulo a b))))</lang>
(else (gcd a (modulo b a)))))</lang>


or using the standard function included with Scheme (takes any number of arguments):
or using the standard function included with Scheme (takes any number of arguments):