A simple algorithm to compute the least common multiple of two numbers

LCM(x, y)

Arguments

x

an object of class numeric

y

an object of class numeric

Value

The least common multiple of x and y.

Examples

LCM(5,7)
#> [1] 35
LCM(5,8)
#> [1] 40
LCM(5,9)
#> [1] 45
LCM(5,10)
#> [1] 10
Reduce(LCM, 1:10) # -> 2520
#> [1] 2520