Here is a present value equation which is a geometric sequence
i = monthly int rate
v = 1/(1+i)
20 yr loan (240 months)
155,000 = P(v + v^2 + ...v^240)
15 yr loan (180 months)
155,000 = P(v + v^2+ ...v^180)
Use formula for sum of geometric series:
Sn = v + v^2 + ...vn = v(1−vn) / 1−v
Now you can find the monthly payments for each loan.
Multiply the payment by length of loan to get total payment, subtract loan amount to get total interest paid.
The answer would be $40,013.40.