How many integers $n$ are there such that $1< n < 1000$ and the highest common factor of $n$ and $36$ is $1$?
I have tried counting the prime numbers up to $1000$ using the prime-counting function. But there are of course other numbers like $133$, $77$ which are not prime and yet they satisfy the conditions.
Is there any efficient algorithm to solve this problem?
In order for the greatest common factor of an integer $n$ and $36$ to be $1$, $n$ and $36$ must share no prime divisors. The prime divisors of $36$ are $2$ and $3$.
Thus, the question now becomes:
This is fairly easy to compute by looking at the compliment and utilizing the inclusion/exclusion principle --- let $m_k$ be the number of multiples of $k$ between $1$ and $1000$: \begin{equation} \mathrm{nonmultiples} = 1000 - \left(m_2 + m_3 - m_6\right) \end{equation}
It can also be seen that the value of $m_k$ is $\left\lfloor\frac{1000}{k}\right\rfloor$.