simple-squiggle

A restricted subset of Squiggle
Log | Files | Refs | README

lcm.md (995B)


      1 <!-- Note: This file is automatically generated from source code comments. Changes made in this file will be overridden. -->
      2 
      3 # Function lcm
      4 
      5 Calculate the least common multiple for two or more values or arrays.
      6 
      7 lcm is defined as:
      8 
      9     lcm(a, b) = abs(a * b) / gcd(a, b)
     10 
     11 For matrices, the function is evaluated element wise.
     12 
     13 
     14 ## Syntax
     15 
     16 ```js
     17 math.lcm(a, b)
     18 math.lcm(a, b, c, ...)
     19 ```
     20 
     21 ### Parameters
     22 
     23 Parameter | Type | Description
     24 --------- | ---- | -----------
     25 `args` | ... number &#124; BigNumber &#124; Array &#124; Matrix | Two or more integer numbers
     26 
     27 ### Returns
     28 
     29 Type | Description
     30 ---- | -----------
     31 number &#124; BigNumber &#124; Array &#124; Matrix | The least common multiple
     32 
     33 
     34 ### Throws
     35 
     36 Type | Description
     37 ---- | -----------
     38 
     39 
     40 ## Examples
     41 
     42 ```js
     43 math.lcm(4, 6)               // returns 12
     44 math.lcm(6, 21)              // returns 42
     45 math.lcm(6, 21, 5)           // returns 210
     46 
     47 math.lcm([4, 6], [6, 21])    // returns [12, 42]
     48 ```
     49 
     50 
     51 ## See also
     52 
     53 [gcd](gcd.md),
     54 [xgcd](xgcd.md)