Use recursive functions for toDigits.