fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int a,n,m;
  5. double s=0,q;
  6. cin>>n;
  7. for(int i=1;i<=n;i++){
  8. m=i;
  9. q=1;
  10. for(int j=1;j<=m;j++){
  11. q=q*2;
  12. }
  13. s+=(2*i-1)/q;
  14. }
  15. cout<<s<<endl;
  16. return 0;
  17. }
Success #stdin #stdout 0s 3472KB
stdin
23
stdout
2.99999