When the requirement gcd(m,n)=1does not hold, we can instead look at the equivalences modulo pand qrespectively. Clearly, when gcd(m,n)=n,we have that c≡m≡0modnand our correctness still holds. Now, consider the case m=k⋅p,where we have that c≡m≡0modpand cd≡(me)d(modq).Since we have already excluded the case that gcd(m,q)=q,we can conclude that gcd(m,q)=1,as qis prime. This means that mℓϕ(q)≡1modqand by the multiplicative properties of the ϕfunction, we determine that mℓnϕ(n)=mℓϕ(q)≡1modq.We conclude by invoking the Chinese Remainder theorem with
mm≡0≡1ℓmmodpmodq
that me⋅d≡mmodn.The case for m=k⋅qfollows in a parallel manner.