Ryan has 5 boxes of pencils. Each box contained 8 pencils. He put all the pencils equally into 6 containers. How many pencils are left without a container?

had 40 pencils

6 * 6 = 36 (fits)
7 * 6 = 42 ( Ran out of pencils L(
so
40 - 36 = 4 left over