# Thread: knowledge of n and phi(n) allows factoring of n

1. ## knowledge of n and phi(n) allows factoring of n

How would one factor a product of two primes (n), if they know both n and phi(n)?

2. Let $n = p_1p_2 \ \Leftrightarrow \ p_2 = \frac{n}{p_1} \qquad {\color{red}\star}$.

Then: $\varphi (n) = \varphi (p_1p_2) = \varphi(p_1)\varphi(p_2) = (p_1 - 1)(p_2 - 1)$

So we have: $\varphi (n) = (p_1 - 1) (\frac{n}{p_1}-1)$ by ${\color{red}\star}$

All that we have to do now is solve for $p_1$.