牛牛学数列7
include<stdio.h>
int main()
{long int n,i,f1,f2,f;
scanf("%d",&n);
if(n==1)
{printf("0");}
else
{if(n==2||n==3)
{printf("1");}
else
{f1=f2=1;
for(i=4;i<=n;i++)
{f=f1+f2;
f1=f2;
f2=f;}
printf("%ld",f);}}}
int main()
{long int n,i,f1,f2,f;
scanf("%d",&n);
if(n==1)
{printf("0");}
else
{if(n==2||n==3)
{printf("1");}
else
{f1=f2=1;
for(i=4;i<=n;i++)
{f=f1+f2;
f1=f2;
f2=f;}
printf("%ld",f);}}}
相关推荐