Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner input= new Scanner(System.in);
- int x= input.nextInt();
- double product=1,sum=0;
- for(int i=1;i<=x;i++)
- {
- product*=i;
- sum+=1.0/product;
- }
- System.out.println("The sum is "+sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement