fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. int a,n;
  10. double s=0,q=1;
  11. Scanner in = new Scanner(System.in);
  12. n=in.nextInt();
  13. for(int i=1;i<=n;i++){
  14. q=q*2;
  15. s+=(2*i-1)/q;
  16. }
  17. System.out.println(s);
  18.  
  19. }
  20. }
Success #stdin #stdout 0.12s 29356KB
stdin
3
stdout
1.875