#include <stdio.h>
main()
{
int t,n,a,b,s,i;
while(scanf("%d",&t)!=EOF)
{
while(t--)
{
scanf("%d",&n);
if(n<3)
{
printf("%d\n",n);
}
else
{
for(a=1,b=2,i=3;i<=n;i++)
{
s=a+b;
a=b;
b=s;
}
printf("%d\n",s);
}
}
}
}
注意:
1、做此题,不要急。很容易看出,是一道递推题,所以要找到规律。
2、此题规律为:1,2,3,5,8,13,21……。很容易看出,后一项等于前两项和。