galois.lcm¶
- galois.lcm(*integers)¶
Computes the least common multiple of the integer arguments.
Note
This function is included for Python versions before 3.9. For Python 3.9 and later, this function calls
math.lcm()
from the standard library.- Returns
The least common multiple of the integer arguments. If any argument is 0, the LCM is 0. If no arguments are provided, 1 is returned.
- Return type
Examples
In [1]: galois.lcm() Out[1]: 1 In [2]: galois.lcm(2, 4, 14) Out[2]: 28 In [3]: galois.lcm(3, 0, 9) Out[3]: 0
This function also works on arbitrarily-large integers.
In [4]: prime1, prime2 = galois.mersenne_primes(100)[-2:] In [5]: prime1, prime2 Out[5]: (2305843009213693951, 618970019642690137449562111) In [6]: lcm = galois.lcm(prime1, prime2); lcm Out[6]: 1427247692705959880439315947500961989719490561 In [7]: lcm == prime1 * prime2 Out[7]: True