我使用此代码,但收到分段错误。这里有什么问题?
GNU nano 2.2.6 文件:taak8.c
#include<stdio.h>
double recursie(double som,double oud, double x, int stap){
double y = oud*x/stap;
if(y >= 1/1000){
return recursie(som+y,y,x,stap++);
} else {
return som;
}
}
double exp(double x){
return recursie(1,1,x,1);
}
int main(){
double inp;
scanf("%lf",&inp);
printf("your result %lf",exp(inp));
return 0;
}