fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. long double ret = 0.0, mul = 1.0;
  5. for(int i = 1; i <= 50; i++) mul *= 2.0, ret += 1.0 * i * i / mul;
  6. cout << fixed << setprecision(15) << ret << endl;
  7. return 0;
  8. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
5.999999999997597