Shrunk the digits function by converting it to a recursive function.