Given a quadratic series as given below, the task is to find sum of first n terms of this series.
Sn = 3 + 7 + 13 + 21 + 31 + ….. + upto n terms
Input: N = 3 Output: 23 Input: N = 4 Output: 44
Let the series be represented as
Sn = 3 + 7 + 13 + ... + tn
- Sn represents the sum of the series till n terms.
- tn represents the nth term of the series.
Now, to formulate the series, the elements need to be formed by taking the difference of the consecutive elements of the series.
Equation 1: Sn = 3 + 7 + 13 + 21 + 31 +…..+ tn-1 + tn
Equation 2: Sn = 0 + 3 + 7 + 13 + 21 + 31 + …… + tn-1 + tn
(writing the above series by shifting all elements to right by 1 position)
Now, Subtract Equation 2 from Equation 1 i.e. (Equation 1 – Equation 2)
Sn – Sn = (3 – 0) + (7 – 3) + (13 – 7) + (31 – 21) + …… + (tn- tn-1) – tn
=> 0 = 3 + 4 + 6 + 8 + 10 + …… + (tn – tn-1) – tn
In above series, leaving 3 aside, terms starting from 4 to (tn – tn-1) will form an A.P.
Since formula of sum of n terms of A.P. is:
Sn = n*(2*a + (n – 1)*d)/2
In series: 4 + 6 + 8 + … + (tn – tn-1)
AP is formed with (n-1) terms.
Sum of this series: (n-1)*(2*4 + (n-2)*2)/2
Therefore, the original series:
0 = 3 + (n-1)*(2*4 + (n-2)*2)/2 – tn
where tn = n^2 + n + 1 which is the nth term.
Sum of first n terms of series will be:
tn = n^2 + n + 1
Sn = (n^2) + n + (1)
Sn = n*(n+1)*(n+2)/6 + n*(n+1)/2 + n
Sn = n*(n^2 + 3*n + 5)/3
Below is the implementation of above approach:
Sum = 23
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Print N terms of Withoff Sequence
- Print first N terms of Lower Wythoff sequence
- Count the occurrence of Nth term in first N terms of Van Eck's sequence
- Print n terms of Newman-Conway Sequence
- Print the sequence of size N in which every term is sum of previous K terms
- Find n terms of Fibonacci type series with given first two terms
- Number of quadruples where the first three terms are in AP and last three terms are in GP
- Find the quadratic equation from the given roots
- Check whether one root of the Quadratic Equation is twice of other or not
- Maximum and Minimum value of a quadratic function
- Find if two given Quadratic equations have common roots or not
- Program to find the Roots of Quadratic equation
- Least root of given quadratic equation for value greater than equal to K
- Roots of the quadratic equation when a + b + c = 0 without using Shridharacharya formula
- Check if roots of a Quadratic Equation are reciprocal of each other or not
- Program to find number of solutions in Quadratic Equation
- Boundary Value Analysis : Nature of Roots of a Quadratic equation
- Check if roots of a Quadratic Equation are numerically equal but opposite in sign or not
- Sum of P terms of an AP if Mth and Nth terms are given
- Sum of the series 5+55+555+.. up to n terms
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.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.