2/3-4/5+6/7-8/9+.....
Solution using C++ language:
#include <iostream>
using namespace std;
int main() {
int n = 17,i = 1;
double res = 0.0;
bool sign = true;
while (n > 0) {
n--;
if (sign) {
sign = !sign;
res = res + (double)++i / ++i;
} else {
sign = !sign;
res = res - (double)++i / ++i;
}
}
cout << "The sum of the given series is "<< res;
return 0;
}
Output:
The sum of given series is 0.77152
No comments:
Post a Comment