Two multiplicative functions similar to Mobius inversion 
Let $f:\mathbb N\to\mathbb Z$ be a function satisfying $f(m+n)\equiv f(n)\pmod{m}$ for all $m,n\in\mathbb N$. For a given $n$, let $g(n)=|G|$, where $G=\{k\in[1,n]:n\mid f(k)\}$, and let $h(n)=|H|$, where $H=\{k\in[1,n]:\gcd(n,f(k))=1\}$. Show that $g,h$ are multiplicative and $$h(n)=n\sum_{d\mid n}\mu(d)\frac{g(d)}{d},$$ where $\mu$ is the Mobius function.

I encountered the problem in the context of the Dirichlet convolution, so that is likely to be useful here. Note also that the formula for $h(n)$ in terms of $g(n)$ is similar to the Mobius inversion formula, so that could be significant.
 A: We can even show that $$h(n)=n \sum_{d \mid n} \mu (d) \frac{g(d)}{d} = n \prod_{j=1}^k \left( 1- \frac{g(p_j)}{p_j} \right),$$where $n=p_1^{\alpha_1} \cdots p_k^{\alpha_k}$ is the prime factorization of $n$. In fact, it is easier to obtain $\displaystyle h(n)=n \prod_{j=1}^k \left(1- \dfrac{g(p_j)}{p_j} \right)$ and $\displaystyle n \prod_{j=1}^k \left(1- \dfrac{g(p_j)}{p_j} \right)= n \sum_{d \mid n} \mu (d) \frac{g(d)}{d}$.

Let $m,n$ be positive integers such that $\gcd (m,n)=1$. We need to prove $g(mn)=g(m)g(n)$ and $h(mn)=h(m)h(n)$.
Indeed, from $f(1)$ to $f(m)$, we have $g(m)$ values that are divisible by $m$. Consider $m \mid f(i) \; (1 \le i \le m)$. We have $f(i) \equiv f(mk+i) \pmod{m}$ so $m \mid f(mk+i) \; \forall k \ge 0$. Note that since $\gcd (m,n)=1$ so $i+mk$ for $0 \le k \le n-1$ is a complete residue system modulo $n$. Hence, from $f(i), f(i+m)$ to $f(i+(n-1)m)$ there are $g(n)$ values that are divisible by $n$. Since there are $g(m)$ such $i$, so from $f(1)$ to $f(mn)$, there are $g(m)g(n)$ values that are divisible by $mn$. Or $g(mn)=g(m)g(n)$, which means $g$ is multiplicative. Similarly, $h$ is also multiplicative.
Note that for every prime $p$, $g(p)+h(p)=p$. Therefore, $$n \prod_{j=1}^k \left( 1- \frac{g(p_j)}{p_j} \right) = n \prod_{j=1}^k \frac{h(p_j)}{p_j} = \prod_{j=1}^k h(p_j)p_j^{\alpha_{j}-1}.$$Since $h$ is multiplicative so $h(n)= \prod_{j=1}^kh(p_j^{\alpha_j})$. Thus, it suffices to prove $h(p_j)p_j^{\alpha_j-1}= h\left( p_j^{\alpha_j} \right) \; \forall 1 \le j \le k$.
Indeed, from $f(1)$ to $f(p_j)$ there are $h(p_j)$ values that are relatively prime to $p_j$. Consider $f(i)$ such that $1 \le i \le p_j$ and $\gcd \left( f(i),p_j \right)=1$. Since $f(i+p_jk) \equiv f(i) \pmod{p_j}$ so $p_j \nmid f(i+p_jk)$ for all $k \ge 0$. Therefore, for $1 \le i+p_jk \le p_j^{\alpha_j}$ or $0 \le k \le p^{\alpha_j-1}-1$, there are exactly $p^{\alpha_j}$ values $i+p_jk$ that are relatively prime to $p_j$. Since there are $h(p_j)$ such $i$ so $g(p_j^{\alpha_j})= p_j^{\alpha_j-1}g(p_j)$.

We have shown that $\displaystyle h(n)= n \prod_{j=1}^k \left(1- \dfrac{g(p_j)}{p_j} \right)$. It is obvious that $$\displaystyle n \prod_{j=1}^k \left(1- \dfrac{g(p_j)}{p_j} \right)= n \sum_{d \mid n} \mu (d) \frac{g(d)}{d}$$ according to the definition of Mobius function so we are done.
