Answer the question
In order to leave comments, you need to log in
How to calculate this example (the sum of the series) * (the product of the series) + why does it display such a result?
I came across such an example, I
looked at how and what works, I made just such a program.
#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main()
{
setlocale(LC_ALL, "rus");
double x,s=1,i=1, sumar=0, proizr=1,k=3,n;
cout << "Введите x= ";
cin >> x;
cout << "Введите n = ";
cin >> n;
for (k; k <= n; k++) {
sumar += (pow(-2, k - 1)) / ((k - 5)*pow(x,k));
}
for (i; i < k + 7; i++) {
proizr *= ((pow(i, 3) - 27) / (i - 7));
}
s = sumar * proizr;
cout <<fixed << setprecision(4)<< "s = " << s;
}
for (i; i < k + 7; i++) {
proizr *= ((pow(i, 3) - 27) / (i - 7));
}
Answer the question
In order to leave comments, you need to log in
No way. I didn’t read the whole code, but NaN should turn out there (the denominator of the fraction turns to zero). The task was given by some idiot.
You have an error in that you consider the product once after looping over k. At that moment, k after the loop is equal to n. Those. as if you have n instead of k in the formula as the boundary for the product.
You need to count proizr inside the loop over k and multiply each term by it. (don't forget to initialize proizr with one).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question