Isn't this a lower sec maths question?
Rephrase:
John can finish 1/45 of a task in one minute. Peter can finish 1/30
of a task in one minute.
Working together, they can finish
1/45 + 1/30 = 1/18 of a task in one minute
Hence, to finish one task together, they will need 18 minutes.