Divide $x=123456$ into three factors $x=uvw$ such that $uv^iw$ is divisible by 3 I have the problem of dividing the string 123456 into three factors uvw that such $uv^iw$ as a number is divisible by three, where $\left|uv\right|\le4$ and $\left| v\right|>0$, i.e. the factors u and v should together only be 4 digits long.
I found the answer but just by simply trying out different values. My knowledge in number theory is very limited, I basically just know that a number is divisible by 3 if it contains three in its prime factorization... And I just cannot explain why it is that if I e.g. divide 123456  such that u=12, v=34, w=56 it's the case that for all small values of i, it's the case that $uv^iw$ is divisible by 3: $uv^2w=121156656, uv^3w=123930456, uv^4w=12133633656$ are all divisible by 3, why is that the case?

Shouldn't $v^i$ be repetition of $v$, not a power of the number $v$?  That seems more likely since we are talking about strings.  In that case $u=12,v=34,w=56$ is not correct.  The classic divisibility rule says that a number is a multiple of $3$ if and only if the sum of the digits is.  So as long as the sum of the digits in your string is a multiple of $3$, the whole number is.  If the sum of the digits in $v$ is a multiple of $3$, repeating it will not change the status of the number.
