Look, RSA is built on the fact in the private key (d,n) and the public key (e,n) d and e are exponential inverses of each other mod n. If x^d or x^e are congruent to 1 then d = phi(n) or e = phi(n) respectively... Take a look at Euler's Theorem which is a generalize form of Fermat's Little Theorem. This is why in RSA there is so much care taken in picking keys.
