Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //S(x, n) = 1 + x + x^3/3! + x^5/5! + ... + x^(2n + 1)/(2n + 1)!
- #include <stdio.h>
- #include <conio.h>
- #include <math.h>
- int gt(int k)
- {
- long s=1;
- for(int i=1;i<=k;i++)
- s*=i;
- return s;
- }
- int main()
- {
- int x,n;
- printf("x=");scanf("%d",&x);
- printf("n=");scanf("%d",&n);
- float s=1;
- for(int i=1;i<=n;i++)
- {
- s=s+pow(x,(1.0*(2*i+1)/(gt(2*i+1))));
- }
- printf("S(%d,%d)=%f",x,n,s);
- getch();
- return 0;
- }
Add Comment
Please, Sign In to add comment