Write a program to print the sum of the following series:
S = 1 + (1*2) + 2 + (1*2*3) + 3 + (1*2*3*4) + 4 + (1*2*3*4*5) + 5 .......to N terms
Where N is user input.
Answers
Answered by
0
Answer:
Program to find the sum of a Series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + … + (n*n)
You have been given a series (1*1) + (2*2) + (3*3) + (4*4) + (5*5) + … + (n*n), find out the sum of the series till nth term.
Examples :
Input : n = 3
Output : 14
Explanation : 1 + 1/2^2 + 1/3^3
Input : n = 5
Output : 55
Explanation : (1*1) + (2*2) + (3*3) + (4*4) + (5*5)
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
// CPP program to calculate the following series
#include<iostream>
using namespace std;
// Function to calculate the following series
int Series(int n)
{
int i;
int sums = 0;
for (i = 1; i <= n; i++)
sums += (i * i);
return sums;
}
// Driver Code
int main()
{
int n = 3;
Similar questions
English,
2 months ago
English,
2 months ago
Biology,
5 months ago
Computer Science,
5 months ago
Political Science,
10 months ago