title: Program Print Sum Given Nth Term
signature: func programPrintSumGivenNthTerm(n 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(n int, expected int) string {
      if validateSolution(PLACEHOLDER_FN_NAME(n),expected) {
              return "PASSED"
      }
      return "FAILED"
  
  }
  
  func main() {
  
      // Use imports to avoid undefined errors
      var _ = reflect.DeepEqual
      _ = math.Abs
      _ = sort.Sort
      result := ""
      result = driver(39, 1521)
      fmt.Printf("TEST-0...%s\n", result)
      
      result = driver(20, 400)
      fmt.Printf("TEST-1...%s\n", result)
      
      result = driver(10, 100)
      fmt.Printf("TEST-2...%s\n", result)
      
      result = driver(39, 1521)
      fmt.Printf("TEST-3...%s\n", result)
      
      result = driver(70, 4900)
      fmt.Printf("TEST-4...%s\n", result)
      
      result = driver(21, 441)
      fmt.Printf("TEST-5...%s\n", result)
      
      result = driver(21, 441)
      fmt.Printf("TEST-6...%s\n", result)
      
      result = driver(80, 6400)
      fmt.Printf("TEST-7...%s\n", result)
      
      result = driver(89, 7921)
      fmt.Printf("TEST-8...%s\n", result)
      
      result = driver(99, 9801)
      fmt.Printf("TEST-9...%s\n", result)
      
          
  }
source_py: def program_print_sum_given_nth_term(n):
      S = 0
      for i in range(1, (n + 1)):
          S += ((i * i) - ((i - 1) * (i - 1)))
      return S
source_cpp: int program_print_sum_given_nth_term(long n) {
    int S = 0;
    for ( int i = 1;
    i <= n;
    i ++ ) S += i * i - ( i - 1 ) * ( i - 1 );
    return S;
  }