grandes-ecoles 2021 Q4b
Modular Arithmetic Computation
If $n \in \mathbb{N}^*$, we denote, for $i \in \{0,1,2,3\}$, $$r_i(n) = \operatorname{Card}\{d \in \mathbb{N} : d \equiv i [4] \text{ and } d \mid n\}$$ We set $g(n) = r_1(n) - r_3(n)$.
Show that, for all $n \in \mathbb{N}$, and all prime number $p$, we have $$g\left(p^n\right) = \begin{cases} 1 & \text{if } p = 2 \\ n+1 & \text{if } p \equiv 1 [4] \\ \frac{1}{2}\left(1+(-1)^n\right) & \text{if } p \equiv 3 [4] \end{cases}$$