You can find the least common multiple using prime factorization. Here, lcm(a, b)
has to contain all the prime factors of a
and b
in their highest multiple they appear in in any of the two numbers.
For example, 8 = 2^3
and 12 = 2^2 * 3
, so lcm(8, 12) = 2^3 * 3 = 24
.
This can easily be reversed: Find the prime factors of c
(including their multiplicity), then check which ones already are covered by a
. b
has to be the product of the remaining ones.
So if c = 24 = 2^3 * 3
and a = 6 = 2 * 3
, then b
has to be 8 = 2^3
. The 3^1
is already covered by a
, but a
only has 2^1
, so b
has to be 2^3
.
solved How do I find the least b from lcm(a,b) = c?