OK, I got it. First, prove the following:
1 + 10^a + 10^2a is divisible by 3, for any integer a > 0.
1 + 10^a + 10^2a = (10^3a - 1)/(10-1)
= (1000^a - 1)/9
= ((3*9*37 + 1)^a - 1)/9
Expand by the binomial theorem: the two "1" terms cancel out, and all the other terms are divisible by 3.
Now the main proof:
If k is not a multiple of 3, the previous post shows how to construct a number n with 9n = 0 mod k. Since 3 does not divide k, then n = 0 mod k.
If k is a multiple of 3, let k = 3m.
Construct a number q such that q = 0 mod m. (Note, this is a recursive algorithm, since m may be a multiple of 3.)
Let q = r mod 3m. If r = 0 we are done and n = q.
If r is not 0, then define n to be the digits of q "repeated" three times (for example if q = 30033, n = 300333003330033)
n = 3r mod 3m, and r = 0 mod m, therefore n = 0 mod 3m.