Short answer: for 12 and 18 the GCD is 6 and the LCM is 36. For any pair,GCD × LCM = a × b, which is the quickest way to check an answer by hand.
How the Euclidean algorithm works
18 ÷ 12 leaves 6; 12 ÷ 6 leaves 0. The last non-zero remainder, 6, is the GCD. LCM then comes from (12 × 18) ÷ 6 = 36. The same steps repeat across a list, one number at a time, which is why this handles more than two inputs.
Worked example
Bus A arrives every 12 minutes and bus B every 18. They coincide every LCM(12, 18) = 36 minutes. Cutting a 48 cm × 36 cm sheet into the largest equal squares: GCD(48, 36) = 12 cm squares.