Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. Scanner input= new Scanner(System.in);
  2. int x= input.nextInt();
  3. double product=1,sum=0;
  4. for(int i=1;i<=x;i++)
  5. {
  6. product*=i;
  7. sum+=1.0/product;
  8.  
  9.  
  10. }
  11. System.out.println("The sum is "+sum);
  12. }
  13.  
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement