2021-03-09
作者:互联网
/* 求前20项斐波那契数列的和
1 1 2 3 5 8 13 …
*/
#include <stdio.h>
/* 求前20项斐波那契数列的和
1 1 2 3 5 8 13 ....
*/
int main(int argc, char *argv [])
{
int i, sum = 2;
int a[20] = {1,1};
for(i = 2; i < 20; i++)
{
a[i] = a[i - 1] + a[i - 2];
sum += a[i];
}
printf("sum is %d\n", sum);
return 0;
}
标签:03,13,20,int,求前,sum,09,项斐波,2021 来源: https://blog.csdn.net/Zhou_zilv/article/details/114582901