As an exercise in my discrete mathematics textbook, for my first-year course, the following question is asked, on the topic of RSA encryption: Show that we can easily factor $n$ when we know that $n$ is the product of two primes, $p$ and $q$, and we know the value of $(p-1)(q-1)$.
So far my attempted solution has been to expand $(p-1)(q-1)$, to lay a foundation of the known value. $$(p-1)(q-1)=pq-p-q+1$$ and rewrite $$(p-1)(q-1)=pq-(p+q)+1$$ The book suggests calling $p+q=s$ and then attempting to use that to find the product $n$, since $q=s-p$, we can write the product as $n=p(s-p)$. Expanding this leads to the quadratic equation $$0=p^2-ps+n$$ Using the quadratic formula to solve this leads to the following solution: $$p=\frac{s\pm\sqrt{s^2-4n}}{2}$$ As shown by @misterriemann in the comments, the discriminant can not be negative, which leaves out any complex solutions, however i am unsure how to extract $q$ from this, after being given $p$ as a function of $s$. Any help on this would be appreciated.
The discriminant cannot be negative, since by AM-GM, $$ \frac{p+q}{2} \geq \sqrt{pq}, $$ and so $$ s^2 = (p+q)^2 \geq 4pq = 4n \quad \Rightarrow \quad s^2-4n \geq 0.$$
Furthermore, since you know the value of $(p-1)(q-1),$ (as well as $n=pq)$, you also know $s$, since $$ s = p+q = pq-(p-1)(q-1)+1. $$
Then you can find $p$ from your formula, which immediately gives you $q$ as well, since $$ p+q=s \quad \iff \quad q=s-p, $$ or if you prefer to do division, $$ n=pq \quad \iff \quad q = \frac{n}{p}. $$