CalcLcm

CalcLcm

CalcLcm[ n1, n2, ... ] returns the least common multiple of integers.

Usages

CalcLcm[ n1, n2, ... ]

CalcLcm[ n1, n2, ... ] returns the smallest positive integer that is a multiple of all of n1, n2, ....

Example in out
The least common multiple of 2 and 3. CalcLcm[ 2, 3 ] 6
Three numbers. CalcLcm[ 2, 3, 5 ] 30
The result is positive, also for negative numbers. CalcLcm[ 12, -8 ] 24

CalcLcm[ list ]

The numbers can also be given as a list. Lists inside the list are included as well.

Example in out
The numbers in a list. CalcLcm[ {4, 6} ] 12
Nested lists. CalcLcm[ {4, {6, 8} } ] 24
Details
  • Zero: CalcLcm[ 0, 5 ] returns 0.
  • Single number: the number itself is returned, including its sign: CalcLcm[ -5 ] returns -5.
  • Non-integers: if an argument is not an integer (such as x or 2.5), CalcLcm is left unevaluated: CalcLcm[ 4, x ] stays CalcLcm[ 4, x ].
Warning

If all numbers are 0, such as CalcLcm[ 0, 0 ], the script stops with an error. Make sure that at least one of the numbers is not 0, for example when the numbers are generated randomly.

See also: CalcGcd, CalcDivisors, FactorInt