Computer Science, asked by bhartimaths86, 6 months ago

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 choudharybhavana1209
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