title: Sum Matrix Element Element Integer Division Row Column 1
signature: function sum_matrix_element_element_integer_division_row_column_1(n)
source_py: def sum_matrix_element_element_integer_division_row_column_1(n):
      ans = 0
      temp = 0
      for i in range(1, (n + 1)):
          if (temp < n):
              temp = (i - 1)
              num = 1
              while (temp < n):
                  if ((temp + i) <= n):
                      ans += (i * num)
                  else:
                      ans += ((n - temp) * num)
                  temp += i
                  num += 1
      return ans
source_cpp: int sum_matrix_element_element_integer_division_row_column_1(int n) {
    int ans = 0, temp = 0, num;
    for ( int i = 1;
    i <= n && temp < n;
    i ++ ) {
      temp = i - 1;
      num = 1;
      while ( temp < n ) {
        if ( temp + i <= n ) ans += ( i * num );
        else ans += ( ( n - temp ) * num );
        temp += i;
        num ++;
      }
    }
    return ans;
  }
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(35, 630)
      print(string.format("TEST-0...%s",result))
  
      result = driver(93, 4371)
      print(string.format("TEST-1...%s",result))
  
      result = driver(7, 28)
      print(string.format("TEST-2...%s",result))
  
      result = driver(81, 3321)
      print(string.format("TEST-3...%s",result))
  
      result = driver(80, 3240)
      print(string.format("TEST-4...%s",result))
  
      result = driver(47, 1128)
      print(string.format("TEST-5...%s",result))
  
      result = driver(7, 28)
      print(string.format("TEST-6...%s",result))
  
      result = driver(41, 861)
      print(string.format("TEST-7...%s",result))
  
      result = driver(59, 1770)
      print(string.format("TEST-8...%s",result))
  
      result = driver(34, 595)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 630, "inputs": {"n": 35}}, {"idx": 1, "outputs": 4371, "inputs": {"n": 93}}, {"idx": 2, "outputs": 28, "inputs": {"n": 7}}, {"idx": 3, "outputs": 3321, "inputs": {"n": 81}}, {"idx": 4, "outputs": 3240, "inputs": {"n": 80}}, {"idx": 5, "outputs": 1128, "inputs": {"n": 47}}, {"idx": 6, "outputs": 28, "inputs": {"n": 7}}, {"idx": 7, "outputs": 861, "inputs": {"n": 41}}, {"idx": 8, "outputs": 1770, "inputs": {"n": 59}}, {"idx": 9, "outputs": 595, "inputs": {"n": 34}}]
question_info.extension: lua
question_info.entry_fn_name: sum_matrix_element_element_integer_division_row_column_1
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__