Daffodil International University
Problem Link
//Please follow from main function
#include<stdio.h>
int main(){
long long int start, end, sum, i, t, n;
scanf("%lld", &t);
while(t--){
start=0, end=1, sum=0;
scanf("%lld", &n);
if(n==0)
{
printf("Fib(%lld) = %d\n",n, 0);
}
else if(n==1){
printf("Fib(%lld) = %d\n",n, 1);
}else{
for(i=1; i<n; i++){
sum=start+end;
start=end;
end=sum;
}
printf("Fib(%lld) = %lld\n",n, sum);
}
}
return 0;
}
0 Comments