# Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2

CServer Side ProgrammingProgramming

A series is a sequence of numbers that have some common traits that each number follows. These mathematical series are defined based on some mathematical logic like every number increases by the same interval( arithmetic progression), every number is increased by the same multiple( geometric progression), and many other patterns.

To find the sum of a series we need to evaluate the series and make a general formula for it. But in the series that is no common declaration that takes place so we have to go through the classical approach by adding each number of the series to a sum variable.

Let's take an example that will make the logic more clear,

sum of series upto 7

sum(7) = 12 + 22 + 32 + 42 + 52 + 62 + 72 = 455

## Example

#include <stdio.h>
int main() {
int i, n, sum=0;
n=17 ;
for ( i = 1; i <= n; i++) {
sum = sum + (2 * i - 1) * (2 * i - 1);
}
printf("The sum of series upto %d is %d", n, sum);
}

## Output

The sum of series upto 17 is 6545