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