title: Sum Pairwise Products 1
signature: sum_pairwise_products_1 <- function(n) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(n, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(n), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          41L, 
          382571L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          50L, 
          834275L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          67L, 
          2645897L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          18L, 
          15675L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          60L, 
          1711355L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          6L, 
          266L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          27L, 
          74907L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          46L, 
          601036L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          50L, 
          834275L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          20L, 
          23485L
      )))
  
  }
  
  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;
  }