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

CServer Side ProgrammingProgramming

#### C in Depth: The Complete C Programming Guide for Beginners

45 Lectures 4.5 hours

#### Practical C++: Learn C++ Basics Step by Step

Most Popular

50 Lectures 4.5 hours

#### Master C and Embedded C Programming- Learn as you go

66 Lectures 5.5 hours

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