Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + …

Given an integer N. The task is to find the sum upto N terms of the given series:

2×3 + 4×4 + 6×5 + 8×6 + … + upto n terms

Examples:

Input : N = 5
Output : Sum = 170

Input : N = 10
Output : Sum = 990


Let the N-th term of the series be tN.
t1 = 2 × 3 = (2 × 1)(1 + 2)
t2 = 4 × 4 = (2 × 2)(2 + 2)
t3 = 6 × 5 = (2 × 3)(3 + 2)
t4 = 8 × 6 = (2 × 4)(4 + 2)
.
.
.
tN = (2 × N)(N + 2)

The sum of n terms of the series,

 Sn = t1 + t2 +... + tn
    =\;\sum_{k=1}^{n} t_{k}
    =\;\sum_{k=1}^{n} 2k(k+2)
    =\;\sum_{k=1}^{n} (2k^{2}+4k)
    =\;\sum_{k=1}^{n}  2k^{2} + \;\sum_{k=1}^{n}  4k
    =2\frac{n(n+1)(2n+1)}{6} + 4\frac{n(n+1)}{2}
    =n(n+1)[ \frac{2n+1}{3} +2]
    =\frac{n(n+1)(2n+7)}{3}

Below is the implementation of above approach:

C++

filter_none

edit
close

play_arrow

link
brightness_4
code

// C++ program to find sum upto
// N term of the series: 
// 2 × 3 + 4 × 4 + 6 × 5 + 8 × 6 + ... 
#include<iostream>
using namespace std;
  
// calculate sum upto N term of series 
void Sum_upto_nth_Term(int n) 
{
    int r = n * (n + 1) * 
                (2 * n + 7) / 3;
    cout << r;
}
  
// Driver code 
int main()
{
    int N = 5;
    Sum_upto_nth_Term(N) ;
    return 0;
}

chevron_right


Java

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to find sum upto
// N term of the series: 
  
import java.io.*;
  
class GFG {
// calculate sum upto N term of series 
static void Sum_upto_nth_Term(int n) 
{
    int r = n * (n + 1) * 
                (2 * n + 7) / 3;
    System.out.println(r);
}
  
// Driver code
    public static void main (String[] args) {
    int N = 5;
    Sum_upto_nth_Term(N);
    }
}

chevron_right


Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program to find sum upto N term of the series:
# 2 × 3 + 4 × 4 + 6 × 5 + 8 × 6 + ...
  
# calculate sum upto N term of series
def Sum_upto_nth_Term(n):
    return n * (n + 1) * (2 * n + 7) // 3
  
# Driver code
N = 5
print(Sum_upto_nth_Term(N))

chevron_right


C#

filter_none

edit
close

play_arrow

link
brightness_4
code

// C# program to find sum upto
// N term of the series: 
// 2 × 3 + 4 × 4 + 6 × 5 + 8 × 6 + ... 
  
using System;
  
class GFG
{
// calculate sum upto N term of series 
static void Sum_upto_nth_Term(int n) 
{
    int r = n * (n + 1) * 
                (2 * n + 7) / 3;
    Console.Write(r);
}
  
// Driver code 
public static void Main()
{
    int N = 5;
    Sum_upto_nth_Term(N);
}
}
  
// This code is contributed 
// by Akanksha Rai(Abby_akku)

chevron_right


PHP

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to find sum upto 
// N term of the series:
// 2 × 3 + 4 × 4 + 6 × 5 + 8 × 6 + ... 
function Sum_upto_nth_Term($n)
{
    $r = $n * ($n + 1) * 
              (2 * $n + 7) / 3;
    echo $r;
}
  
// Driver code
$N = 5;
Sum_upto_nth_Term($N);
  
// This code is contributed 
// by Shashank_Sharma
?>

chevron_right


Output:

170


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.