# Program to print the Sum of series -1 + 2 + 11 + 26 + 47 +…..

Given a number N, the task is to find the sum of first N number of series:

-1, 2, 11, 26, 47, 74, …..

**Examples:**

Input:N = 3Output:12Explanation:Sum = (N * (N + 1) * (2 * N - 5) + 4 * N) / 2 = (3 * (3 + 1) * (2 * 3 - 5) + 4 * 3) / 2 = 12Input:N = 9Output:603

**Approach:**

The Nth term of the given series can be generalised as:

Nth term of the series

Below is the implementation of the above approach:

## C++

`// CPP program to find SUM ` `// upto N-th term of the series: ` `// -1, 2, 11, 26, 47, 74, ..... ` ` ` `#include <iostream> ` `using` `namespace` `std; ` ` ` `// calculate Nth term of series ` `int` `findSum(` `int` `N) ` `{ ` ` ` `return` `(N * (N + 1) * (2 * N - 5) + 4 * N) / 2; ` `} ` ` ` `// Driver Function ` `int` `main() ` `{ ` ` ` ` ` `// Get the value of N ` ` ` `int` `N = 3; ` ` ` ` ` `// Get the sum of the series ` ` ` `cout << findSum(N) << endl; ` ` ` ` ` `return` `0; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java program to find SUM ` `// upto N-th term of the series: ` `// -1, 2, 11, 26, 47, 74, ..... ` `import` `java.util.*; ` ` ` `class` `solution ` `{ ` ` ` `static` `int` `findSum(` `int` `N) ` `{ ` ` ` `return` `(N * (N + ` `1` `) * (` `2` `* N - ` `5` `) + ` `4` `* N) / ` `2` `; ` `} ` ` ` `//driver function ` `public` `static` `void` `main(String arr[]) ` `{ ` ` ` `// Get the value of N ` ` ` `int` `N = ` `3` `; ` ` ` ` ` `// Get the sum of the series ` ` ` `System.out.println(findSum(N)); ` ` ` `} ` `} ` `//THis code is contributed by ` `//Surendra_Gangwar ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 program to find sum ` `# upto N-th term of the series: ` `# -1, 2, 11, 26, 47, 74, ..... ` ` ` `# calculate Nth term of series ` `def` `findSum(N): ` ` ` ` ` `return` `((N ` `*` `(N ` `+` `1` `) ` `*` ` ` `(` `2` `*` `N ` `-` `5` `) ` `+` `4` `*` `N) ` `/` `2` `) ` ` ` `#Driver Function ` `if` `__name__` `=` `=` `'__main__'` `: ` ` ` ` ` `#Get the value of N ` ` ` `N ` `=` `3` ` ` ` ` `#Get the sum of the series ` ` ` `print` `(findSum(N)) ` ` ` `#this code is contributed by Shashank_Sharma ` |

*chevron_right*

*filter_none*

## C#

`// C# program to find SUM ` `// upto N-th term of the series: ` `// -1, 2, 11, 26, 47, 74, ..... ` `using` `System; ` ` ` `class` `GFG ` `{ ` `static` `int` `findSum(` `int` `N) ` `{ ` ` ` `return` `(N * (N + 1) * ` ` ` `(2 * N - 5) + 4 * N) / 2; ` `} ` ` ` `// Driver Code ` `static` `public` `void` `Main () ` `{ ` ` ` `// Get the value of N ` ` ` `int` `N = 3; ` ` ` ` ` `// Get the sum of the series ` ` ` `Console.Write(findSum(N)); ` `} ` `} ` ` ` `// This code is contributed by Raj ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP program to find SUM ` `// upto N-th term of the series: ` `// -1, 2, 11, 26, 47, 74, ..... ` ` ` `// calculate Nth term of series ` `function` `findSum(` `$N` `) ` `{ ` ` ` `return` `(` `$N` `* (` `$N` `+ 1) * ` ` ` `(2 * ` `$N` `- 5) + 4 * ` `$N` `) / 2; ` `} ` ` ` `// Driver Code ` ` ` `// Get the value of N ` `$N` `= 3; ` ` ` `// Get the sum of the series ` `echo` `findSum(` `$N` `) . ` `"\n"` `; ` ` ` `// This code is contributed ` `// by Akanksha Rai(Abby_akku) ` `?> ` |

*chevron_right*

*filter_none*

**Output:**

12

**Time Complexity:** O(1)

## Recommended Posts:

- Program to print the series 2, 1, 4, 3, 6, 5, .... up to N terms
- Program to print binomial expansion series
- Program to print Arithmetic Progression series
- Program to print triangular number series till n
- Print Number series without using any loop
- Print first N terms of series (0.25, 0.5, 0.75, ...) in fraction representation
- Program for sum of cos(x) series
- Program to find sum of series 1*2*3 + 2*3*4+ 3*4*5 + . . . + n*(n+1)*(n+2)
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + . . . + n
- Program to find Sum of the series 1*3 + 3*5 + ....
- Program to find the sum of a Series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + ... + (n*n)
- Program for sum of arithmetic series
- Program to find the sum of the series (1/a + 2/a^2 + 3/a^3 + ... + n/a^n)
- Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n!

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.