User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:gcd [2019/06/15 02:00]
cl:functions:gcd [2019/08/17 15:00] (current)
Line 1: Line 1:
 +====== Function GCD ======
 +
 +====Syntax====
 +  * **gcd** //''&​rest''​ integers// → //​greatest-common-denominator//​
 +
 +====Arguments and Values====
 +  * //integer// - an //​[[CL:​Glossary:​integer]]//​.
 +  * //​greatest-common-denominator//​ - a non-negative //​[[CL:​Glossary:​integer]]//​.
 +
 +====Description====
 +Returns the greatest common divisor of //​integers//​. If only one //integer// is supplied, its absolute value is returned. If no //​integers//​ are given, **[[CL:​Functions:​gcd]]** returns ''​0'',​ which is an identity for this operation.
 +
 +====Examples====
 +<​blockquote>​
 +(gcd) <​r>​0</​r>​
 +(gcd 60 42) <​r>​6</​r>​
 +(gcd 3333 -33 101) <​r>​1</​r>​
 +(gcd 3333 -33 1002001) <​r>​11</​r>​
 +(gcd 91 -49) <​r>​7</​r>​
 +(gcd 63 -42 35) <​r>​7</​r>​
 +(gcd 5) <​r>​5</​r>​
 +(gcd -4) <​r>​4</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should signal an error of type **[[CL:​Types:​type-error]]** if any //integer// is not an //​[[CL:​Glossary:​integer]]//​.
 +
 +====See Also====
 +  * **[[CL:​Functions:​lcm|Function LCM]]**
 +
 +====Notes==== ​
 +For three or more arguments:
 +
 +<​blockquote> ​
 +(gcd b c ... z) ≡ (gcd (gcd a b) c ... z) 
 +</​blockquote>​
 +