fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n = 1000;
  6. double s = 0;
  7. for(int i = 1; i < n; i++)
  8. { double x = (i % 2 ? 1.0 : -1.0) * (2*i-1);
  9. for(int j = 1; j <= i; j++)
  10. x /= 3;
  11. s += x;
  12. } cout << s;
  13. return 0;
  14. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
0.125