If n^{th} term of a sequence is given by Tn=an^{3}+bn^{2}+cn+d where a, b, c, d are constants then sum of n terms.

S_{n = }a*Σ(n^{3})+b*Σ(n^{2})+c*Σ(n)+Σ(d)

where Σ represent summation.

**Proof :**

Let us find some of this series. So,

S_{n}= T_{1}+T_{2}+T_{3}+T_{4}+ ... +T_{n}T_{1}= a(1)^{3}+b(1)^{2}+c(1)+d T_{2}= a(2)^{3}+b(2)^{2}+c(2)+d T_{3}= a(3)^{3}+b(3)^{2}+c(3)+d ... ... T_{n}= a(n)^{3}+b(n)^{3}+c(n)+d

adding these all terms,

Sn = T_{1}+T_{2}+T_{3}+ ... +T_{n}= a((1)^{3}+(2)^{3}+(3)^{3}+ ... +(n)^{3})+b((1)^{2}+(2)^{2}+(3)^{2}+ ... +(n)^{2})+c(1+2+3+ ... +n)+d(1+1+1+ ... +1)

Sn = a*Σ(n^{3})+b*Σ(n^{2})+c*Σ(n)+dn

Similarly if we have been nth term for any higher order or lower order term in the format.

T_{n = }a_{1}n^{p}+a_{2}n^{p-1}+a_{3}n^{p-2}++ ... +a_{p}n^{1}+a^{p+1}

Sn = a_{1}Σ(n^{p})+a_{2}Σ(n^{p-1})+a_{3}Σ(n^{p-2})+ ... +a_{p}Σ(n)+na_{p+1}

where p, a1, a2, …… are some constants.

**Example :**

nth term is given as,

T_{n}= n^{2}+n+1

Calculate S_{n}

**Explanation :**

S_{n}= Σ(T_{n}) S_{n}= Σ(n^{2})+Σ(n)+Σ(1) S_{n}= (n(n+1)(2n+1))/6+n(n+1)/2+n

Because,

Σ(n^{2}) = (n(n+1)(2n+1))/6, Σ(n) = (n(n+1))/2, Σ(1) = n

Thus we can find sum of any sequence if its nth term is given. This article is helpful in finding time complexity of equations when time complexity is given as function of n and we have to find the time complexity for the whole algorithm.

`#include <bits/stdc++.h> ` `using` `namespace` `std; ` `int` `main() ` `{ ` ` ` `int` `k = 3; ` ` ` `int` `sum = 0; ` ` ` `// finding sum of n^4 terms ` ` ` `for` `(` `int` `i = 1; i <= k; i++) ` ` ` `sum += (i * i * i * i); ` ` ` `// sum of first k natural numbers is k(k+1)/2. ` ` ` `sum += (k * (k + 1)) / 2; ` ` ` `// we can also use code to calculate it ` ` ` `// for(int i=1;i<=k;i++) ` ` ` `// sum+=i; ` ` ` ` ` `// sum of constant term 1 for n times is n ` ` ` `sum += k; ` ` ` `// we can also use code to calculate it. ` ` ` `// for(int i=1;i<=k;i++) ` ` ` `// sum+=1; ` ` ` `cout << sum << endl; ` `} ` |

*chevron_right*

*filter_none*

**Output :**

107

The given code above finds summation of sequence for 3 terms in which,

T_{n}= n^{4}+n+1

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Rough Set Theory | Properties and Important Terms | Set - 2
- Finding nth term of any Polynomial Sequence
- Mathematics | Sequence, Series and Summations
- Mathematics | Sum of squares of even and odd natural numbers
- Z-test
- Levene's test
- Alpha and Beta test
- Previous Solved CS Papers Year wise - GATE / UGC / ISRO
- Solving Homogeneous Recurrence Equations Using Polynomial Reduction
- Mathematics | Problems On Permutations | Set 1
- GRE | List of words to enhance your vocabulary with root alphabet 'H'
- Puzzle | Form Three Equilateral Triangles
- Puzzle | Six Houses P, Q, R, S, T, and U
- Vocabulary for CAT and Aptitude Related Exams | Set 2

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.