You need to prove that if then the homomorphism is well-defined, i.e. if (for all ). And conversely, i.e. if (for all ) then . You proved the first part correctly. We can do it easier. If then since it means (divisibility is transitive). For the second part you overkilled it. Assume that (for all ), choose then and so .

Because you proved it both ways. You said if it is well-defined then it can only be when . And then you should that if then it is well-defined. Thus, you found precisely the numbers for which is works.how do I know these are the only m and n for which this works?