title: Sum Pairwise Products 1
signature: sumPairwiseProducts1(n) {
test_code: import 'dart:convert';
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  bool validateSolution(int actual, int expected){
      return actual.toString() == expected.toString();
  }
  
  String driver(n, int expected){
      try
      {
          if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)){
              return "PASSED";
          }
          return "FAILED";
      }catch(exception_object){
          return exception_object.runtimeType.toString();
      }
  }
  
  int main() {
  
      print("TEST-0...${driver(
          41, 
          382571)
      }");
  
      print("TEST-1...${driver(
          50, 
          834275)
      }");
  
      print("TEST-2...${driver(
          67, 
          2645897)
      }");
  
      print("TEST-3...${driver(
          18, 
          15675)
      }");
  
      print("TEST-4...${driver(
          60, 
          1711355)
      }");
  
      print("TEST-5...${driver(
          6, 
          266)
      }");
  
      print("TEST-6...${driver(
          27, 
          74907)
      }");
  
      print("TEST-7...${driver(
          46, 
          601036)
      }");
  
      print("TEST-8...${driver(
          50, 
          834275)
      }");
  
      print("TEST-9...${driver(
          20, 
          23485)
      }");
  
      return 0;
  }
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;
  }