code: def calculate_first_digit(number):
      
  
      sum = 0
      if len(number) == 9:
          weights = CPF_WEIGHTS[0]
      else:
          weights = CNPJ_WEIGHTS[0]
  
      for i in range(len(number)):
          sum = sum + int(number[i]) * weights[i]
      rest_division = sum % DIVISOR
      if rest_division < 2:
          return '0'
      return str(11 - rest_division)
docs: This function calculates the first check digit of a
          cpf or cnpj.
  
          :param number: cpf (length 9) or cnpf (length 12) 
              string to check the first digit. Only numbers.
          :type number: string
          :returns: string -- the first digit