title: Sum K Th Group Odd Positive Numbers
signature: func sumKThGroupOddPositiveNumbers(k int) int {
test_code: package main
  
  import (
      "fmt"
      "reflect"
      "math"
      "sort"
  )
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  func validateSolution(actual int, expected int) bool {
      return reflect.DeepEqual(actual,expected)
  }
  
  func driver(k int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(k),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(91, 753571)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(52, 140608)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(78, 474552)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(51, 132651)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(65, 274625)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(39, 59319)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(42, 74088)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(12, 1728)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(56, 175616)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(98, 941192)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
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;
  }