fork(1) download
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4. public static Scanner in = new Scanner(System.in);
  5. public static void main(String[]args) {
  6.  
  7. double a=in.nextDouble();
  8. double s =1;
  9. double p=1;
  10. double m=1;
  11. int l=1;
  12. for(int i=1;i<(a+1);i++)
  13. {
  14.  
  15.  
  16. for(;l<=i;l++)
  17. {
  18. p=p*l;
  19.  
  20. }
  21.  
  22. s=s+m/p;
  23. }
  24.  
  25.  
  26. System.out.print(s);
  27.  
  28.  
  29. }
  30.  
  31. }
Success #stdin #stdout 0.12s 37120KB
stdin
4
stdout
2.708333333333333