User Tools


Differences

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

Link to this comparison view

cl:functions:lcm [2019/06/15 02:00]
cl:functions:lcm [2019/09/16 13:00] (current)
Line 1: Line 1:
 +====== Function LCM ======
 +
 +====Syntax====
 +  * **lcm** //''&​rest''​ integers// → //​least-common-multiple//​
 +
 +====Arguments and Values====
 +  * //integer// - an //​[[CL:​Glossary:​integer]]//​.
 +  * //​least-common-multiple//​ - a non-negative //​[[CL:​Glossary:​integer]]//​.
 +
 +====Description====
 +**lcm** returns the least common multiple of the //​integers//​. If no //integer// is supplied, the //​[[CL:​Glossary:​integer]]//​ ''​1''​ is returned. If only one //integer// is supplied, the absolute value of that //integer// is returned.
 +
 +For two arguments that are not both zero:
 +
 +<​blockquote>​
 +(lcm a b) ≡ ([[CL:​Functions:​math-divide|/​]] ([[CL:​Functions:​abs]] ([[CL:​Functions:​math-multiply|*]] a b)) ([[CL:​Functions:​gcd]] a b))
 +</​blockquote>​
 +
 +If one or both arguments are zero"
 +
 +<​blockquote>​
 +(lcm a 0) ≡ (lcm 0 a) ≡ 0
 +</​blockquote>​
 +
 +For three or more arguments:
 +
 +<​blockquote>​
 +(lcm a b c ... z) ≡ (lcm (lcm a b) c ... z)
 +</​blockquote>​
 +
 +====Examples====
 +<​blockquote>​
 +(lcm 10) <​r>​10</​r>​
 +(lcm 25 30) <​r>​150</​r>​
 +(lcm -24 18 10) <​r>​360</​r>​
 +(lcm 14 35) <​r>​70</​r>​
 +(lcm 0 5) <​r>​0</​r>​
 +(lcm 1 2 3 4 5 6) <​r>​60</​r>​
 +</​blockquote>​
 +
 +====Side Effects====
 +None.
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should signal **[[CL:​Types:​type-error]]** if any argument is not an //​[[CL:​Glossary:​integer]]//​.
 +
 +====See Also====
 +  * **[[CL:​Functions:​gcd|Function GCD]]**
 +
 +====Notes====
 +None.
 +
 +\issue{LCM-NO-ARGUMENTS:​1}