- 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

# Program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+ a^n/n! in C++

In this problem, we are given two numbers a and n. Our task is to create a *program to find Sum of a Series a^1/1! + a^2/2! + a^3/3! + a^4/4! +…….+
a^n/n! in C++*.

**Problem description** − The problem is to find the sum of the given series using the given values of a and n. The series is a special series in which each term is the multiple of the last term with a/i, i -> 1 to n.

**Let’s take an example to understand the problem**

## Input

a = 3, n = 4

## Output

15.375

## Explanation

sum of series is

(3^1)/1! + (3^2)/2! + (3^3)/3! + (3^4)/4! = 3 + 9/2 + 27/6 + 81/24 = 15.375

## Solution Approach

To find the sum of the series, we will use loops to find the ith term of the series and add them to find the sum.

The computation of each element of the series directly has calculation overhead. So, we will use last term to find the next term.

Here, ith term = (i-1)th term * a/i.

Using this we will find terms with less calculations that improves the overall performance of the code.

**Program to illustrate the working of our solution**

## Example

#include <iostream> using namespace std; float calcSeriesSum(int a, int n){ float sumVal = 0, term = 1; for(float i = 1; i <= n; i++){ term *= a/i; sumVal += term; } return sumVal; } int main(){ int a = 3, n = 4; cout<<"The sum of the series is "<<calcSeriesSum(a, n); return 0; }

## Output

The sum of the series is 15.375

- Related Questions & Answers
- C++ Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! + …… n/n!
- Python Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Java Program to find the sum of a Series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- Sum of the series 1 + (1+2) + (1+2+3) + (1+2+3+4) + ... + (1+2+3+4+...+n) in C++
- C++ program to find the sum of the series 1/1! + 2/2! + 3/3! + 4/4! +…….+ n/n!
- C++ program to find the sum of the series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + … + (n*n)
- C++ program to find the sum of the series (1/a + 2/a^2 + 3/a^3 + … + n/a^n)
- Program to find sum of series 1 + 1/2 + 1/3 + 1/4 + .. + 1/n in C++
- Sum of the Series 1/(1*2) + 1/(2*3) + 1/(3*4) + 1/(4*5) + ... in C++
- Find Sum of Series 1^2 - 2^2 + 3^2 - 4^2 ... upto n terms in C++
- C++ Programe to find n-th term in series 1 2 2 3 3 3 4
- C++ program to find the sum of the series 1 + 1/2^2 + 1/3^3 + …..+ 1/n^n
- Program to find sum of series 1 + 2 + 2 + 3 + 3 + 3 + .. + n in C++
- Sum of the series 1^1 + 2^2 + 3^3 + ... + n^n using recursion in C++
- Sum of series 1^2 + 3^2 + 5^2 + . . . + (2*n – 1)^2