Calculates residuo