Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int factorial(int value)
  4. {
  5. return (value < 2) ? (1) : (value*factorial(value - 1));
  6. }
  7.  
  8. double Y(double x)
  9. {
  10. return exp(cos(x)) * cos(sin(x));
  11. }
  12.  
  13. void S(float from, float to, int n)
  14. {
  15. int fact = 1;
  16. int multiplier = 1;
  17. float sum = 1;
  18. for (float i = from; i < to ; i += (to - from) / n )
  19. {
  20. printf("Y(%f) = %f\t\t", i, Y(i));
  21. sum += (cos(multiplier * i) / factorial(fact));
  22. printf("S(%f) = %f\n", i, sum);
  23. }
  24. }
  25.  
  26. int main()
  27. {
  28. S(0.1, 1, 10);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement