A problem about number of functions and homomorphism I'm trying to solve this problem.

How many functions $f: \Bbb Z_{10}\rightarrow \Bbb Z_3$ are there such that $|f^{-1}([0]_3)| = 3$ or $|f^{-1}([1]_3)| = 4$?
How many of them are such that the restriction to the multiplicative group of $Z_{10}$ is a homomorphism (basically the domain is the multiplicative group of $\Bbb Z_{10}$ and the codomain the multiplicative group of $\Bbb Z_{3}$).

I start from the assumption that I'm not sure I understood the problem and that I have some difficulties for the second question. Anyway, this is my reasoning. Any help is welcome.
Since $|f^{-1}([0]_3)| = 3$ we know that only three elements in $\Bbb Z_{10}$ are associated by the function to $[0]_3$. So I exclude these three elements since they are already associated and for the definition of function, I can not associate them further. I exclude $[0]_3$ because otherwise if I could associate other elements $|f^{-1}([0]_3)| \neq 3$. So basically I have now $7$ elements of $\Bbb Z_{10}$ which I can associate to $1,2 \in \Bbb Z_3$. For this reason, there are $2^7$ possible function. Same reasoning for $|f^{-1}([1]_3)| = 4$. Is that correct?
For the second question, I found online that the number of homomorphism between two cyclic groups is the GCD of their order. First of all, can someone explain to me why the GCD? It is an information that I miss from the study of group theory or that I have neglected.
So I need to know the order of the two multiplicative groups. I use the Euler totient function to do this and I obtain $4$ for the multiplicative group of $\Bbb Z_{10}$ and $2$ for $\Bbb Z_3$. Now $gcd(2,4) = 2$ so there are two homomorphism (?).  
Is my reasoning correct? 
 A: For the first problem your reasoning is not correct. To count just the functions for which the inverse image of the class $[0]_3$ has $3$ elements, you need to first consider which elements, which gives $\binom{10}3$ choices, and then how to assign the remaining $10-3=7$ elements to the remaining $2$ classes, which can be done in $2^7$ manners; all in all $\binom{10}32^7=15360$ functions. Similarly for the inverse image of the class $[1]_3$ to have $4$ elements, there are $\binom{10}42^6=13440$ functions. But the question is how many functions have one or the other, so you need some inclusion-exclusion. The number of functions that satisfy both constraints is the trinomial coefficient $\binom{10}{3,4,3}=4200$ (since knowing the inverse images of two classes forces whatever is left to be the inverse image of the third class $[2]_3$), and those functions are counted twice if one just takes the sum of the numbers for both conditions individually, so $4200$ needs to be subtracted from that sum, giving as final result $15360+13440-4200=24600$.
For the second problem you evidently need to study the multiplicative groups in question a bit first. You seem to assume that a multiplicative group of some ring $\def\Z{\Bbb Z}\Z/n\Z$ is always cyclic; this is not true (for instance it fails for $n=8$). It happens to be true though for $n=3$ (as the group has order $2$) and for $n=10$ (the powers of $3$ being successively $1,3,9,7,1,\ldots$ modulo$~10$ and exhausting the classes forming the multiplicative group). The latter means a homomorphism of the multiplicative group modulo$~10$ is entirely determined by the image of the class $[3]_{10}$, and it is easy to see that both elements of the  multiplicative group modulo$~3$ are candidates for that image, so there are $2$ such homomorphisms. This does not mean however that there are just two functions whose restriction is such a homomorphism, since the restriction says nothing about the images of the $10-4=6$ classes that are not in the multiplicative group modulo$~10$, and for each of them we can choose any of the $3$ classes modulo$~3$ as image. The answer to the second problem is therefore $2\times3^6=1458$.
