Assume the number does not have 2 or 5 as a prime factor. If it does, simply extend this solution by multiplying by 10 until you get a multiple of n.

Consider the number m = 3n. m is relatively prime to 10. So by Euler's theorem, there exists an x such that:
10^x = 1 mod m
etc.

Edit this page