计算2/1+3/2+5/3+8/5+..
2023-01-31 01:01:22
计算
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
double a = 1.0;
double b = 1.0;
double Sn = 0;
int i = 0;
for (i = 0; i < 20; i++)
{
a = a + b;
b = a - b;
Sn += (a / b);
}
printf("Sn=%f\n", Sn);
system("pause");
return 0;
}
相关文章