title: Sum K Th Group Odd Positive Numbers
signature: function sum_k_th_group_odd_positive_numbers(k)
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(k, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(k) 
      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(91, 753571)
      print(string.format("TEST-0...%s",result))
  
      result = driver(52, 140608)
      print(string.format("TEST-1...%s",result))
  
      result = driver(78, 474552)
      print(string.format("TEST-2...%s",result))
  
      result = driver(51, 132651)
      print(string.format("TEST-3...%s",result))
  
      result = driver(65, 274625)
      print(string.format("TEST-4...%s",result))
  
      result = driver(39, 59319)
      print(string.format("TEST-5...%s",result))
  
      result = driver(42, 74088)
      print(string.format("TEST-6...%s",result))
  
      result = driver(12, 1728)
      print(string.format("TEST-7...%s",result))
  
      result = driver(56, 175616)
      print(string.format("TEST-8...%s",result))
  
      result = driver(98, 941192)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
source_py: def sum_k_th_group_odd_positive_numbers(k):
      cur = int(((k * (k - 1)) + 1))
      sum = 0
      while k:
          sum += cur
          cur += 2
          k = (k - 1)
      return sum
source_cpp: int sum_k_th_group_odd_positive_numbers(int k) {
    int cur = ( k * ( k - 1 ) ) + 1;
    int sum = 0;
    while ( k -- ) {
      sum += cur;
      cur += 2;
    }
    return sum;
  }