24 = 2 × 2 × 2 × 3 = 23 × 3
36 = 2 × 2 × 3 × 3 = 22 × 32
40 = 2 × 2 × 2 × 5 = 23 × 5
HCF = product of smallest power of each common prime factor in the numbers = 22 = 4
LCM = product of greatest power of each prime factor involved in the numbers = 23 × 32 × 5 = 360