#include "stdio.h"
#include "time.h"
_int64 fun(_int64 n)
{
_int64 s;
if(n==0||n==1) return 1;
s=(fun(n-1)+fun(n-2));
return s;
}
int main()
{
clock_t start,finish;
start=clock();
_int64 a=1000000000;
_int64 b=9999999999;
_int64 i=1,tmp;
_int64 fib[20]={0},index=0;
while(1)
{
tmp=fun(i);
if(tmp<a) {i++; continue;}
if(tmp>=a && tmp<=b)
{
fib[index]=tmp;
index++;
}
i++;
if(tmp>b) break;
if(index>1)
{
while(1)
{
fib[index]=fib[index-1]+fib[index-2];
if(fib[index]+fib[index-1]>b) goto _exit;
index++;
}
}
}
_exit:
printf("\n Fibonacci数列中位于 %I64d 和 %I64d 之间的数共有%I64d个.\n",a,b,index);
printf("分别是:\n");
for(i=1;i<20;i++) if(fib[i]!=0) printf("%I64d\n",fib[i]);
finish=clock();
printf("计算Fibonacci数列共耗时%.3lf秒,好艰难啊",((double)finish-start)/1000);
return 0;
}