Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- double total = 1, a = 1, b = 1, b2 = 1.5;
- int i = 0, n = 0;
- scanf("%d", &n);
- for (i = 2; i <= n; i++)
- {
- a = a *2; b++;b2 += 1.5;
- if(i % 2 == 0)
- {
- total += a / b2;
- }
- else if(i % 2 != 0)
- {
- total += b / a;
- }
- }
- printf("S: %.2lf", total);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement