
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Find the Sum of the Series 2+3, 4+5, 7+5 Up to N Terms in C++
In this tutorial, we will be discussing a program to find the sum of the given series 23+ 45+ 75+….. upto N terms.
For this, we will be given with the value of N and our task is to add up every term starting from the first one to find the sum of the given series.
After solving this, we get the formula for the sum of the series;
Sn = (2n(n+1)(4n+17)+54n)/6
Example
#include <iostream> using namespace std; //calculating the sum of the series int calc_sum(int N) { int i; int sum = (2 * N * (N + 1) * (4 * N + 17) + 54 * N) / 6; return sum; } int main() { int N = 7; int res = calc_sum(N); cout << res << endl; return 0; }
Output
903
Advertisements