Each minute, the first pipe fills 1/40 of the tank and the second pipe fills 1/60 of the tank. If it takes x minutes for both pipes working together to fill the tank, then, each minute, 1/x of the tank gets filled.
So, 1/40 + 1/60 = 1/x
Multiply both sides by the LCD, 120x:
3x + 2x = 120
5x = 120
x = 24 minutes