Add q to p, add a to the result, then divide r by what you have Add q to p: p + q Add a to the result: p + q + a Then divide r by what you have: r/(p + q + a)