Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main() {
- int n, i;
- double difference, realSum, currentSum = 0;
- scanf("%d", &n);
- for (i = 1; i / 2 <= n; i = i + 2){
- currentSum = currentSum + 1.0 / (i * (i + 1) * (i + 2));
- }
- realSum = log(2.0) - 1.0/2.0;
- difference = realSum - currentSum;
- printf("the difference between the total sum and the sum of the first %d terms is %f", n, difference);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement