![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2
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
Advertisements