#include <stdio.h>
main(){
int a=0,b=1,c,sum=0,n,i;
printf("请输入整数\n");
scanf("%d",&n);
for(i=1;i<=n;i++){
c=a+b;
sum=sum+b;
a=b,b=c;
}
printf("斐波那契数列的前%d项和为%d",n,sum);
}
(图文无关)接上,求斐波那契数列前N项和
最新推荐文章于 2022-12-22 00:06:51 发布