title: Sum Pairwise Products 1
signature: fun sumPairwiseProducts1(n: Int): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(41, 382571)
      println("TEST-0...${result}")
      
      result = driver(50, 834275)
      println("TEST-1...${result}")
      
      result = driver(67, 2645897)
      println("TEST-2...${result}")
      
      result = driver(18, 15675)
      println("TEST-3...${result}")
      
      result = driver(60, 1711355)
      println("TEST-4...${result}")
      
      result = driver(6, 266)
      println("TEST-5...${result}")
      
      result = driver(27, 74907)
      println("TEST-6...${result}")
      
      result = driver(46, 601036)
      println("TEST-7...${result}")
      
      result = driver(50, 834275)
      println("TEST-8...${result}")
      
      result = driver(20, 23485)
      println("TEST-9...${result}")
      
          
  }
  
  main()
source_py: def sum_pairwise_products_1(n):
      multiTerms = ((n * (n + 1)) // 2)
      sm = multiTerms
      for i in range(2, (n + 1)):
          multiTerms = (multiTerms - (i - 1))
          sm = (sm + (multiTerms * i))
      return sm
source_cpp: long long int sum_pairwise_products_1(int n) {
    long long int multiTerms = n * ( n + 1 ) / 2;
    long long int sum = multiTerms;
    for ( int i = 2;
    i <= n;
    i ++ ) {
      multiTerms = multiTerms - ( i - 1 );
      sum = sum + multiTerms * i;
    }
    return sum;
  }