- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- 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 with alternate signed squares of AP

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

## Explanation

12 - 22 + 32 - 42 = -10

## Example

#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; }

## Output

The sum of series is -36

- 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++
- Sum of the alternate nodes of linked list in C++
- Difference between sum of the squares of and square of sum first n natural numbers.
- JavaScript code to find nth term of a series - Arithmetic Progression (AP)
- 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
- 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
- Sum of perimeter of all the squares in a rectangle using JavaScript
- Is a number sum of two perfect squares in JavaScript
- Get the Least squares fit of Chebyshev series to data in Python

Advertisements