We must follow "PEMDAS" rules for "order of operations."
Multiplication and division must be done before addition and subtraction:
40q = p + (p/3) + (p/9) + p/27
The LCD of this expression is 27. 1, 3 and 9 all divide evenly into 27. The equation thus becomes:
27(40q) = 27p + 9p + 3p + p
Adding up the four "p" terms, we get 40p. Then 27(40q) = 40p.
Simplifying thru division by 40, 27q = p. Alternatively, p = 27q.
Find the ratio of p to q by dividing both sides by q: (p/q) = 27 (answer)