Hold on, the code he has seems to work perfectly for me (unchanged).
OP, recompile it and test again.
10 to the 0 = 1 * 3 = 3, 0+3 = 3, a = 3 on that iteration.
and requirements that force you to use this are terrible. at the very least getting rid of the pow() would be good. And a little creativity would make it O(1) ish. I mean, 111 * 3 is 333. 111*9 is 999. The function could be reduced to return X*Y (or at worst, x*lookup[y]).