public static double sumseries(int n)
{
//numerator:分子;denomirator:分母
double numerator = 1, denominator = 1;
double sum = 0,temp = 0;
for (int i = 1; i<=n; i++)
{
temp = denominator;
denominator = numerator;
numerator = numerator + temp;
sum = sum + numerator/denominator;
}
return sum;
}
楼主,请试试这个 |