title: Program Print Sum Given Nth Term
signature: function programPrintSumGivenNthTerm($n) {
test_code: <?php
  
  
  // SOLUTION CODE 
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function validateSolution($actual, $expected){
      return serialize($actual) == serialize($expected);
  }
  
  function driver($n, $expected){
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME($n), $expected)){
          return "PASSED";
        }
        return "FAILED";
      }
      catch (Exception $exception_obj) {
        return get_class($exception_obj);
      }
  }
  
  function main(){
      printf("TEST-0...%s\n",driver(
        39, 
        1521));
      
      printf("TEST-1...%s\n",driver(
        20, 
        400));
      
      printf("TEST-2...%s\n",driver(
        10, 
        100));
      
      printf("TEST-3...%s\n",driver(
        39, 
        1521));
      
      printf("TEST-4...%s\n",driver(
        70, 
        4900));
      
      printf("TEST-5...%s\n",driver(
        21, 
        441));
      
      printf("TEST-6...%s\n",driver(
        21, 
        441));
      
      printf("TEST-7...%s\n",driver(
        80, 
        6400));
      
      printf("TEST-8...%s\n",driver(
        89, 
        7921));
      
      printf("TEST-9...%s\n",driver(
        99, 
        9801));
      
  }
  
  main();
  ?>
source_py: def program_print_sum_given_nth_term(n):
      S = 0
      for i in range(1, (n + 1)):
          S += ((i * i) - ((i - 1) * (i - 1)))
      return S
source_cpp: int program_print_sum_given_nth_term(long n) {
    int S = 0;
    for ( int i = 1;
    i <= n;
    i ++ ) S += i * i - ( i - 1 ) * ( i - 1 );
    return S;
  }