二项式求问题,为什么出来的数字超级超级长?
#include<stdio.h>
#include<math.h>
int main()
{
double f1(double a[], double x, int n);
double a[6];
f1(a, 1.0, 5);
printf("%lf", f1(a, 1.0, 5));
return 0;
}
double f1(double a[], double x, int n)
{
double total = a[0];
int i;
for (i = 1;i < n;i++)
{
a[i] = (double)i;
total += a[i] * pow(x, i);
}
return total;
}