m/p = (a+b)/b and n/p = (a+b)/a
you can simplify this to
m/p = a/b + b/b or more simply,
m/p = a/b + 1 and through the same process n/p = 1 + b/a
solve each for a/b
a/b = m/p - 1
which is also a/b = (m-p)/p
and by the same process
b/a = (n-p)/p
take the reciprocal so a/b = p/(n-p)
since a/b is equal to a/b, substitute
(m-p)/p = p/(n-p)
cross multiply
(m-p)(n-p) = p
2simplify
mn - pn - pm + p
2 = p
2mn = p(n+m)
solve for p
p = mn/(m+n)