The larger triangle, and the smaller triangle that fits inside the larger, are similr triangles.
So we can form the proportion x/5 = 48/8 Note how x/5 is the result of dividing the larger vertical side (x) over the smaller vertical side (5) The same applies with 48/8. The larger triangle's horizontal side is 8+40 = 48. The corresponding horizontal side for the smaller triangle is 8
Cross multiply to solve for x x/5 = 48/8 8*x = 5*48 8*x = 240 8*x/8 = 240/8 x = 30