Need better complexity soln hint for this ques

brute force would be to check every number between 1 to n and find number divisible by prime but it is O(10^18)
So i need a little hint for this kind of ques

@gagangoyal674
This question is based on concept of inclusion exclusion
Lets say N is 20
You need to find number divisible by 3 and 5
It will be N/3 + N/5 - N/15
N/15 because some numbers overlap between multiples of 3 and 5

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.