Is there a formula to find the number of integers $k$ such that $\gcd(k,n)=d$?

74 Views Asked by At

Here $0\le k\lt n$ and $d\mid n$.
All are positive.


I know that the number of integers satisfying $\gcd(k,n)=1$ is $\phi(n)$.
Initially, I thought that the formula would be simply $\phi(n/d)$ because $\gcd(k,n) = d \implies \gcd(k,n/d)=1$.
Soon I realized that this is a mistake : $\gcd(2, 12) = 2 \not \implies \gcd(2,6)=1$.

So I'm kinda stuck looking for a formula. Appreciate any help. Thanks!

1

There are 1 best solutions below

3
On BEST ANSWER

I think your formula is correct, because $\gcd(k,n)=d\Longrightarrow \gcd(k/d,n/d)=1$ and $\gcd(j,n/d)=1 \Longrightarrow \gcd(jd,n)=d$.