C 语言 fibonacci
#include <stdio.h>#define size_t long long
size_t fibo(int);
int main(void)
{
int a=0;
scanf("%d",&a);
printf("fibio a = %lld\n",fibo(a));
return 0;
}
size_t fibo(int a)
{
long long i=0,j=1,sum=0,k=0;
for (k=0;k<=a;k++)
{
i=j;
j=sum;
sum=i+j;
}
return sum;
}
页:
[1]