Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double fact(double x)
- {
- if (!x)
- return 1;
- return (fact(x - 1) * x);
- }
- double sinx(double x)
- {
- const unsigned int N = 50;
- double result = 0;
- unsigned int n;
- for (n = 1; n <= N; ++n)
- result += ((pow(-1, n + 1) * pow(x, 2 * n - 1))
- / fact(2 * n - 1));
- return result;
- }
- int main()
- {
- double sx = sinx(0.8);
- printf("%f \n", sx);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment