Let $q=\prod P\_i^{k\_i}.$
I have learned [here](https://mathoverflow.net/questions/260257/sum-of-sum-substack1aq-a-q1-a1-q11) that $\# \{ 1 \leq a \leq q-1| (a,q)=1, (a+1,q)=1 \}= F(q)=\prod (p\_i-2)pi^{k\_i-1}
= q\prod (1-2/p\_i)$


Here was the idea behind it : For any $p\_i$, there exists $p\_i-2$ admissible reminders modulo $p\_i$ (we exclude 0 and -1) thus $(p\_i-2)p\_i^{k\_i-1}$ reminders modulo $p\_i^{k\_i}$. We get $F(q)$ by applying the Chinese Reminder Theorem.


I am now trying to find what would happen if instead of (a,q)=1 and (a+1,q)=1, we would have $(a,q)=1$ and $(a+2,q)=1$? (with $ 1\leq a+2 \leq q$)


I want to find : 
$\# \{ 1 \leq a \leq q-2| (a,q)=1, (a+2,q)=1 \}$


I dont know if we could apply the same principle. We would still have $(p\_i-2)$ reminders modulo $p\_i$. I am not quite sure. 



What is the general formula for $\# \{ 1 \leq a \leq q-2,| (a,q)=1, (a+2,q)=1 \}$
When $q=\prod\_ip\_i^{k\_i}$ is odd,
$$\# \{ 1 \leq a \leq q-2\, \vert \, (a,q)=1, (a+2,q)=1 \}
=-1+q\prod\_i\left(1-\frac2{p\_i}\right),$$
because the only number you miss (compared to your former problem) is $q-1$ which satisfies $(q-1,q)=1$ and $(q-1+2,q)=1$.


If $q$ is even, then
$$\# \{ 1 \leq a \leq q-2\, \vert \, (a,q)=1, (a+2,q)=1 \}
=-1+\frac{q}2\prod\_{p\_i\neq 2}\left(1-\frac2{p\_i}\right).$$
Argue similarly.


