12 = 2 × 2 × 3
15 = 3 × 5
18 = 2 × 3 × 3
We need enough factors of 2,3, and 5 to cover all the factors in each input, i.e. the maximum power of each prime factor gets multiplied to form the LCM.
The max powers are: 12 has 2 twos, 15 has 1 five and 18 as 2 threes.
LCM = 2 × 2 × 5 × 3 × 3 = 180