What did we do in the days before the modulo operator? (in another language such as BASIC). We were still able to solve these problems...
X - X / 10 * 10
This scales the number down for the next...