Implemented toDigitsRev function.