6-28 for循环
内容纲要
//?Q求出1000以内的完数
//有一分数序列 1/2,2/3,3/5,5/8,8/13,13/21
{
double firsta = 1;
double firstb = 2;
double firstc = 0;
double seconda = 0;
double secondb = 0;
double secondc = secondb / seconda;
double sum = 0;
for (int i = 0; i < 20; i++)
{
seconda = firstb;
secondb = firsta + firstb;
firstc = firstb / firsta;
cout << firstc << endl;
firstb = secondb;
firsta = seconda;
sum += firstc;
}
cout << sum;
system("pause");
}