Every 4th student is wearing cap i.e. it is divisible by 4.
And every 5th is wearing a coat. i.e. it is divisible by 5.
So, if we want to find out which student is wearing both cap and coat, we need to find the LCM of 4 and 5.
LCM of 4 and 5 = 4 × 5 = 20. Since they are co-prime numbers, their LCM will be the product of these numbers.
So, 20th student in a row will be wearing both a cap and a coat.