Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<math.h>
  3.  
  4. int main() {
  5. int n, i;
  6. double difference, realSum, currentSum = 0;
  7. scanf("%d", &n);
  8. for (i = 1; i / 2 <= n; i = i + 2){
  9. currentSum = currentSum + 1.0 / (i * (i + 1) * (i + 2));
  10. }
  11. realSum = log(2.0) - 1.0/2.0;
  12. difference = realSum - currentSum;
  13. printf("the difference between the total sum and the sum of the first %d terms is %f", n, difference);
  14. return 0;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement