We claim that the only integers that work are prime powers pk in which p≡5 or 7 modulo 8. Let define ω,Ω as function from the set of odd integers to {0;1} by
ω(n)={01if n≡1,3(mod8)if n≡5,7(mod8)
and
Ω(n)≡∣{k∣0<k<n/4,gcd(k,n)=1}∣(mod2).
Then we want to find n such that Ω(n)=1. It is easy to verify
ω(ab)≡ω(a)+ω(b)(mod2)(†)
Let n=p1a1p2a2…pkak which p1,p2,…,pk are distinct primes and a1,a2,…,ak are integers. Note that n=1 does not work so consider k≥1.
Lemma: Ω(n)≡ω(n)+∑1≤i≤kω(pin)+∑1≤i<j≤kω(pipjn)+⋯+ω(p1p2…pkn)(mod2).
Proof: the idea to proof this lemma is similar to prove the Euler totient function. It is easy to check that ω(n) is indeed the parity of ∣{k∣0<k<n/4}∣=⌊4n⌋. To remove numbers divisible by some p, one can subtract from above the value
∣{pk∣0<k<n/(4p)}∣=∣{k∣0<k<(n/p)/4}∣=ω(pn).
But that removes numbers divisible by pq (for p=q) twice so we will add ω(pq) then continue as the principle of inclusion and exclusion, we add until ω(p1p2…pkn). Note that the formula should be added and subtracted alternatively but since we consider modulo 2 so all of the signs can be consider as plus. Back to the original problem, by applying the lemma and (†), one can get
Ω(n)+1≤i≤k∑ω(pi)+1≤i<j≤k∑ω(pipj)+⋯+ω(p1p2…pk)≡ω(n)+(1≤i≤k∑ω(pin)+1≤i≤k∑ω(pi))+⋯+(ω(p1p2…pkn)+ω(p1p2…pk))≡(0k)ω(n)+(1k)ω(n)+(2k)ω(n)+⋯+(kk)ω(n)≡2kω(n)≡0(mod2).
From this, one can conclude that
Ω(n)≡ω(1)+1≤i≤k∑ω(pi)+1≤i<j≤k∑ω(pipj)+⋯+ω(p1p2…pk)=i=1∑k((0k−1)+(1k−1)+⋯+(k−2k−1))ω(pi)=2k−1i=1∑nω(pi)=2k−1ω(p1p2…pk)(mod2).
Thus if k≥2 then Ω(n)=0 and if k=1, then n=pk, in this case we can check that Ω(n)=ω(p)=1 if and only if p≡5 or 7 modulo 8. □