There's another problem, if you go from 9 up to 0, the variable changes to 10. If you keep going up to put in, say, the first digit "3," the variable would be 13, and wouldn't work.
Also I'm aware I have no say in this but I feel the need to point out these problems.