Solution:
Setting y=0 in the condition (ii), we get
(f(x)−f(0))f(x)=0
for all x (since f(0)=0). Thus either f(x)=0 or f(x)=f(0), for all x∈Z. Now taking x=y=0 in (i), we see that f(0)+f(0)2=2f(0). This shows that f(0)=0 or f(0)=1. Since f(0)=0, we must have f(0)=1. We conclude that
either f(x)=0 or f(x)=1 for each x∈Z
This shows that the set of all possible values of f(x) is {0,1}. This completes (a).
Let S={n∈Z∣f(n)=0}. Hence we must have S={n∈Z∣f(n)=1} by (a). Since f(1)=0, 1 is not in S. And f(0)=1 implies that 0∈S. Take any x∈Z and y∈S. Using (ii), we get
f(xy)+f(x)=f(x)+1
This shows that xy∈S. If x∈Z and y∈Z are such that xy∈S, then (ii) gives
1+f(x)f(y)=f(x)+f(y)
Thus (f(x)−1)(f(y)−1)=0. It follows that f(x)=1 or f(y)=1; i.e., either x∈S or y∈S. We also observe from (ii) that x∈S and y∈S implies that f(x−y)=1 so that x−y∈S. Thus S has the properties:
(A) x∈Z and y∈S implies xy∈S;
(B) x,y∈Z and xy∈S implies x∈S or y∈S;
(C) x,y∈S implies x−y∈S.
Now we know that f(10)=0 and f(2)=0. Hence f(10)=1 and 10∈S; and 2∈/S. Writing 10=2×5 and using (B), we conclude that 5∈S and f(5)=1. Hence f(5k)=1 for all k∈Z by (A).
Suppose f(5k+l)=1 for some l, 1≤l≤4. Then 5k+l∈S. Choose u∈Z such that lu≡1(mod5). We have (5k+l)u∈S by (A). Moreover, lu=1+5m for some m∈Z and
(5k+l)u=5ku+lu=5ku+5m+1=5(ku+m)+1
This shows that 5(ku+m)+1∈S. However, we know that 5(ku+m)∈S. By (C), 1∈S which is a contradiction. We conclude that 5k+l∈/S for any l, 1≤l≤4. Thus
S={5k∣k∈Z}