- Related Questions & Answers
- 8086 program to generate AP series of n numbers
- Sum of squares of binomial coefficients in C++
- Sum of squares of Fibonacci numbers in C++
- JavaScript code to find nth term of a series - Arithmetic Progression (AP)
- Sum of the alternate nodes of linked list in C++
- C++ Program for sum of arithmetic series
- Difference between sum of the squares of and square of sum first n natural numbers.
- C++ Program for Sum of squares of first n natural numbers?
- Sum of squares of first n natural numbers in C Program?
- Python Program for Sum of squares of first n natural numbers
- C Program for sum of cos(x) series
- Program for sum of geometric series in C
- Minimize the sum of squares of sum of N/2 paired formed by N numbers in C++
- Sum of squares of the first n even numbers in C Program
- Java Program to calculate Sum of squares of first n natural numbers

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

An arithmetic progression (AP) is a series of numbers in which the difference between two consecutive terms in the same. The difference is calculated by subtracting the second term from the first.

Let's take a sample sequence to know about AP,

5, 7, 9, 11, 13, 15, . . . The common difference(d) of this arithmetic progression is 2. This means every succeeding element differs the former one by 2. The first term (a) of this series is 5.

The general formula for finding the nth term is a{n} = a + (n-1)(d)

In this problem, we are given an AP and we need to find the sum of series with alternate signed square, the series will look like,

a_{1}^{2} - a_{2}^{2} + a_{3}^{2} - a_{4}^{2} + a_{5}^{2} +......

Let's take an example, to make this more clear −

Input: n = 2 Output: -10

12 - 22 + 32 - 42 = -10

#include <stdio.h> int main() { int n = 4; int a[] = { 1, 2, 3, 4, 5, 6, 7, 8}; int res = 0; for (int i = 0; i < 2 * n; i++) { if (i % 2 == 0) res += a[i] * a[i]; else res -= a[i] * a[i]; } printf("The sum of series is %d", res); return 0; }

The sum of series is -36

Advertisements