Answer the question
In order to leave comments, you need to log in
Why doesn't it calculate the complex construction k / (i*(i + 1)*(i + 2));?
Prompt why does not want to calculate the entire structure entirely?
We have to write the denominator in a separate variable.
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
double step, result;
double znam;
int i, k;
result = 0;
i = 1;
k = 1;
do
{
//не вычисляет! step = 0, хотя должен 0,166667
step = k / (i*(i + 1)*(i + 2));
/*
будет работать только так
znam = i*(i + 1)*(i + 2);
step = k / znam;
*/
result += step;
cout << i << " " << step << "\n";
_getch();
k = -k;
i++;
} while (i <= 5);
cout << "Result: " << result;
_getch();
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question