Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<malloc.h>
- double exp(double x, int n, int *fakt, double *xpot) {
- return *xpot / *fakt + (n == 0 ? 0 : exp(x, n - 1, fakt - 1, xpot - 1));
- }
- int main(void) {
- double x, *xpot,*A;
- int n, *fakt;
- int i;
- scanf("%d", &n);
- scanf("%lf", &x);
- xpot = (double*)malloc(n * sizeof(double));
- A = (double*)malloc(n * sizeof(double));
- fakt = (int*)malloc(n * sizeof(int));
- xpot[0] = 1;
- fakt[0] = 1;
- for (i = 0; i < n; i++) {
- if (i > 0) {
- *(xpot + i) = x*(*(xpot + i - 1));
- *(fakt + i) = i*(*(fakt + i - 1));
- }
- *(A + i) = exp(x, i, fakt + i, xpot + i);
- printf("%lf ", *(A + i));
- }
- free(A);
- free(xpot);
- free(fakt);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement