Let’s assume x to be the speed of the stream.
So, we know that
Speed of boat in downstream = (5 + x) and,
Speed of boat in upstream = (5 – x)
It is given that,
The distance in one way is 40 km.
And,
Time taken during upstream = 3 × time taken during the downstream
Expressing it by equations, we have
40/ (5 – x) = 3 x 40/ (5 + x) [∵ time = distance/ speed]
By cross multiplication, we get
(5+x) = 3(5-x)
⇒ 5 + x = 3(5 – x)
⇒ x + 3x = 15 – 5
⇒ x = 10/4 = 2.5
Therefore, the speed of the stream is 2.5 km/hr.