# Find the sum of first N terms of the series 2*3*5, 3*5*7, 4*7*9, …

Given an integer **N**, the task is to find the sum of first **N** terms of the series:

(2 * 3 * 5), (3 * 5 * 7), (4 * 7 * 9), …

**Examples:**

Input:N = 3

Output:387

S_{3}= (2 * 3 * 5) + (3 * 5 * 7) + (4 * 7 * 9) = 30 + 105 + 252 = 387

Input:N = 5

Output:1740

**Approach:** Let the **N ^{th}** term of the series be

**T**. Sum of the series can be easily found by observing the

_{n}**N**term of the series:

^{th}

T= {n_{n}^{th}term of 2, 3, 4, …} * {n^{th}term of 3, 5, 7, …} * {n^{th}term of 5, 7, 9, …}

T= (n + 1) * (2 * n + 1) * (2* n + 3)_{n}

T_{n}= 4n^{3}+ 12n^{2}+ 11n + 3

Sum(**S _{n}**) of first n terms can be found by

S= Σ_{n}T_{n}

S= Σ[4n_{n}^{3}+ 12n^{2}+ 11n + 3]

S_{n}= (n / 2) * [2n^{3}+ 12n^{2}+ 25n + 21]

Below is the implementation of the above approach:

## C++

`// C++ program to find sum of the ` `// first n terms of the given series ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// Function to return the sum of the ` `// first n terms of the given series ` `int` `calSum(` `int` `n) ` `{ ` ` ` `// As described in the approach ` ` ` `return` `(n * (2 * n * n * n + 12 * n * n + 25 * n + 21)) / 2; ` `} ` ` ` `// Driver code ` `int` `main() ` `{ ` ` ` `int` `n = 3; ` ` ` `cout << calSum(n); ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Python

`# C++ program to find sum of the ` `# first n terms of the given series ` ` ` `# Function to return the sum of the ` `# first n terms of the given series ` `def` `calSum(n): ` ` ` ` ` `# As described in the approach ` ` ` `return` `(n` `*` `(` `2` `*` `n` `*` `n ` `*` `n ` `+` `12` `*` `n` `*` `n ` `+` `25` `*` `n ` `+` `21` `))` `/` `2` `; ` ` ` `# Driver Code ` `n ` `=` `3` `print` `(calSum(n)) ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find sum of the ` `// first n terms of the given series ` `class` `GFG { ` ` ` ` ` `// Function to return the sum of the ` ` ` `// first n terms of the given series ` ` ` `static` `int` `calSum(` `int` `n) ` ` ` `{ ` ` ` ` ` `// As described in the approach ` ` ` `return` `(n * (` `2` `* n * n * n + ` `12` `* n * n + ` `25` `* n + ` `21` `)) / ` `2` `; ` ` ` `} ` ` ` ` ` `// Driver Code ` ` ` `public` `static` `void` `main(String args[]) ` ` ` `{ ` ` ` `int` `n = ` `3` `; ` ` ` `System.out.println(calSum(n)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find sum of the ` `// first n terms of the given series ` `using` `System; ` ` ` `class` `GFG { ` ` ` ` ` `// Function to return the sum of the ` ` ` `// first n terms of the given series ` ` ` `static` `int` `calSum(` `int` `n) ` ` ` `{ ` ` ` ` ` `// As described in the approach ` ` ` `return` `(n * (2 * n * n * n + 12 * n * n + 25 * n + 21)) / 2; ` ` ` `} ` ` ` ` ` `// Driver code ` ` ` `static` `public` `void` `Main() ` ` ` `{ ` ` ` `int` `n = 3; ` ` ` `Console.WriteLine(calSum(n)); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP script to find sum of the ` `// first n terms of the given series ` ` ` `// Function to return the sum of the ` `// first n terms of the given series ` `function` `calculateSum(` `$n` `) ` `{ ` ` ` ` ` `// As described in the approach ` ` ` `return` `(` `$n` `*(2*` `$n` `*` `$n` `*` `$n` `+12*` `$n` `*` `$n` `+25*` `$n` `+21))/2; ` `} ` ` ` `// Driver code ` `$n` `= 3; ` `echo` `calculateSum(` `$n` `); ` ` ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

387

## Recommended Posts:

- Find n terms of Fibonacci type series with given first two terms
- Find the sum of first N terms of the series 2×3 + 4×4 + 6×5 + 8×6 + ...
- Find the sum of n terms of the series 1,8,27,64 ....
- Find the sum of all the terms in the n-th row of the given series
- Find sum of the series ?3 + ?12 +......... upto N terms
- Find the sum of series 0.X + 0.XX + 0.XXX +... upto k terms
- Find the sum of series 3, -6, 12, -24 . . . upto N terms
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ..... upto n terms
- Find the sum of the series 1+11+111+1111+..... upto n terms
- Find sum of the series 1+22+333+4444+...... upto n terms
- Program to find the sum of the series 23+ 45+ 75+..... upto N terms
- Sum of the first N terms of the series 2,10, 30, 68,....
- Sum of first n terms of a given series 3, 6, 11, .....
- Sum of the first N terms of the series 5,12, 23, 38....
- Sum of the first N terms of the series 2, 6, 12, 20, 30....

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.