WAP in java to Display the sum of the series, where s = 1/3 + 2/5 + 3/6 + ……… 9/12 by any method. Please give the answer in Scanner mode and with messages if you can. Thank you
Answers
Answered by
2
Answer:
Explanation:
Input : 3
Output : 9
Explanation: So here the tern of the sequence upto n = 3 are:
1, 3, 5 And hence the required sum is = 1 + 3 + 5 = 9
Input : 6
Output : 36
// CPP program to find summation of series
#include <bits/stdc++.h>
using namespace std;
int summingSeries(long n)
{
// use of loop to calculate
// sum of each term
int S = 0;
for (int i = 1; i <= n; i++)
S += i * i - (i - 1) * (i - 1);
return S;
}
// Driver Code
int main()
{
int n = 100;
cout << "The sum of n term is: "
<< summingSeries(n) << endl;
return 0;
}
Similar questions