Sum of the first N terms of the series 5,12, 23, 38…. in C Programming


To find the sum of the given series, we will analyze the series and try to get some traits that show it is known series or at least is a combination of 2 - 3 series. the given series is 5, 12, 23, 38…

We have to find the sum of the series for any value of n

For example

For n = 3
Sum = 40.

On analyzing the given series, you will find that this series is Quadratic series. In quadratic series, the difference of the numbers is in an arithmetic progression( increase by definite number)

So we can directly use the formula for the sum of a quadratic series. the formula for the sum of the series is:

Sum = (2*(n*(n+1)*(2*(n+1))/6))+n*(n+1)/2+2*n

Example

#include <stdio.h>
int main() {
   int n = 6;
   int sum = (2*(n*(n+1)*(2*n+1)/6)+(n*(n+1)/2)+(2*n));
   printf("the sum of series till %d is %d", n,sum);
   return 0;
}

Output

the sum of series till 6 is 215
raja
Published on 09-Aug-2019 11:30:37
Advertisements