Given a set $S = \left\{1, 2, \ldots,N \right\}$ of positive integers, we want to count the number of subsets of size $k$ with the GCD of all elements (henceforth referred to as the GCD of the set) equal to $j$ for every $j$ from $1$ to $N$.
I was able to reason out the following:
Define $f(i)$ to be the number of subsets of size $k$ with GCD $i$. Let $g(i)$ be the number of all subsets of size $k$ with GCD divisible by $i$. $g(i)$ is easy to compute. The GCD of a set is divisible by $i$ iff each element of the set is divisible by $i$. So the $g(i)$ is the number of $k$-combinations of multiples of $i$ less than or equal to $N$.
$$g(i) = \binom{\lfloor\frac{N}{i}\rfloor}{k}$$
Also, $g(i)$ and $f(i)$ are related by,
$$g(i) = \sum_{j=1}^{\lfloor\frac{N}{i}\rfloor}f(ij) \tag{1}$$
One simple way to use this relationship is to calculate all $f(i)$s in descending order starting from $f(n)$. However, the solution uses Mobius Inversion somehow.
$$f(i) = \sum_{j=1}^{\lfloor\frac{N}{i}\rfloor}\mu(j)g(ij) \tag{2}$$
This seems to be quite different from the traditional Mobius inversion formula. How can I go from $(1)$ to $(2)$?