problem 112, digit functions