added tail recursive implementation of sum_digit