title: Sum Pairwise Products 1
signature: def sumPairwiseProducts1(n: Int) = {
test_code: import scala.collection.mutable.HashMap
  import scala.collection.immutable.HashSet
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  
  // TESTING CODE 
  // ============================================
  def validateSolution(actual: Int , expected: Int): Boolean = {
      actual.toString == expected.toString
  }
  
  def driver(n: Int, expected: Int): String = {
      try {
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)) {
              "PASSED"
          } else{
              "FAILED"
          }
      }catch{
          case e: Exception => {e.getClass.getName}
      }
  
  }
  object QuestionEvaluator extends App {
  
      println(s"TEST-0...${driver(
        41, 
        382571    
      )}")   
  
  
      println(s"TEST-1...${driver(
        50, 
        834275    
      )}")   
  
  
      println(s"TEST-2...${driver(
        67, 
        2645897    
      )}")   
  
  
      println(s"TEST-3...${driver(
        18, 
        15675    
      )}")   
  
  
      println(s"TEST-4...${driver(
        60, 
        1711355    
      )}")   
  
  
      println(s"TEST-5...${driver(
        6, 
        266    
      )}")   
  
  
      println(s"TEST-6...${driver(
        27, 
        74907    
      )}")   
  
  
      println(s"TEST-7...${driver(
        46, 
        601036    
      )}")   
  
  
      println(s"TEST-8...${driver(
        50, 
        834275    
      )}")   
  
  
      println(s"TEST-9...${driver(
        20, 
        23485    
      )}")   
  
  }
  
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;
  }