Guest User

Untitled

a guest
Nov 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. //S(x, n) = 1 + x + x^3/3! + x^5/5! + ... + x^(2n + 1)/(2n + 1)!
  2. #include <stdio.h>
  3. #include <conio.h>
  4. #include <math.h>
  5. int gt(int k)
  6. {
  7. long s=1;
  8. for(int i=1;i<=k;i++)
  9. s*=i;
  10. return s;
  11. }
  12. int main()
  13. {
  14. int x,n;
  15. printf("x=");scanf("%d",&x);
  16. printf("n=");scanf("%d",&n);
  17. float s=1;
  18. for(int i=1;i<=n;i++)
  19. {
  20. s=s+pow(x,(1.0*(2*i+1)/(gt(2*i+1))));
  21. }
  22. printf("S(%d,%d)=%f",x,n,s);
  23. getch();
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment