title: Sum Matrix Element Absolute Difference Row Column Numbers 2
signature: sum_matrix_element_absolute_difference_row_column_numbers_2 <- 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(
          12L, 
          572L
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          89L, 
          234960L
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          76L, 
          146300L
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          2L, 
          2L
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          81L, 
          177120L
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          11L, 
          440L
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          26L, 
          5850L
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          35L, 
          14280L
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          16L, 
          1360L
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          66L, 
          95810L
      )))
  
  }
  
  main()
source_py: def sum_matrix_element_absolute_difference_row_column_numbers_2(n):
      n -= 1
      sum = 0
      sum += ((n * (n + 1)) / 2)
      sum += (((n * (n + 1)) * ((2 * n) + 1)) / 6)
      return int(sum)
source_cpp: int sum_matrix_element_absolute_difference_row_column_numbers_2(int n) {
    n --;
    int sum = 0;
    sum += ( n * ( n + 1 ) ) / 2;
    sum += ( n * ( n + 1 ) * ( 2 * n + 1 ) ) / 6;
    return sum;
  }