//Just Fibonacci series
#include <stdio.h>
int main()
{ int cases,i;
long long add[51];
add[0]=1;
add[1]=1;
for(i=2;i<51;i++){
add[i]=add[i-2]+add[i-1];
}
while(1){
scanf("%d",&cases);
if(cases==0)
break;
printf("%lld\n",add[cases]);
}
return 0;
}
#include <stdio.h>
int main()
{ int cases,i;
long long add[51];
add[0]=1;
add[1]=1;
for(i=2;i<51;i++){
add[i]=add[i-2]+add[i-1];
}
while(1){
scanf("%d",&cases);
if(cases==0)
break;
printf("%lld\n",add[cases]);
}
return 0;
}
No comments:
Post a Comment