The trick is this:


I think I can do it in How to achieve it: Now, why is this optimal?



This is a special case of a more general problem: How to find the $N$th positive integer coprime to $k$? The important thing to know is that Therefore, to find the $N$th positive integer coprime to $k$, we first So basically, to solve this general problem you only need to know and then the rest is just basic arithmetic.


Essentially the same problem as FizzBuzz. But this is just looking for a closed-form rather than a heuristic solution.


Find the prime factorization of the modulus: 3^1*5^1 For each prime number in the factorization, take the prime number reduced by one power times one less than the prime number, and then multiply all of those numbers together. In this case, both prime numbers are raised to the first power, so reducing the power leaves just p^0, or 1. So we have (3-1)(5-1) = ...

Only top voted, non community-wiki answers of a minimum length are eligible