I think it has something to do with the base you use. If you use base 9(from 0 to 8) you will always get 8. If you use base 8(from 0 to 7) you get 7 and so on.
So the thing is that just before you get to 1 digit(18 for example) you subtract 8(the second digit) and 1 so after subtracting the second digit you always get 10 or in other words the base you use. And then subtract 1 you get one less.