title: Sum Pairwise Products 2
signature: function sum_pairwise_products_2(n)
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 math.abs(actual - expected) < 1e-09
  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(57, 1397887.0)
      print(string.format("TEST-0...%s",result))
  
      result = driver(18, 15675.0)
      print(string.format("TEST-1...%s",result))
  
      result = driver(97, 11449977.0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(9, 1155.0)
      print(string.format("TEST-3...%s",result))
  
      result = driver(42, 420497.0)
      print(string.format("TEST-4...%s",result))
  
      result = driver(67, 2645897.0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(71, 3327486.0)
      print(string.format("TEST-6...%s",result))
  
      result = driver(66, 2493271.0)
      print(string.format("TEST-7...%s",result))
  
      result = driver(69, 2972060.0)
      print(string.format("TEST-8...%s",result))
  
      result = driver(18, 15675.0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def sum_pairwise_products_2(n):
      return ((((n * (n + 1)) * (n + 2)) * ((3 * n) + 1)) / 24)
source_cpp: long long int sum_pairwise_products_2(int n) {
    return n * ( n + 1 ) * ( n + 2 ) * ( 3 * n + 1 ) / 24;
  }