View Code of Problem 3695

#include<stdio.h>
int main(){
	long long f1,f2,s,t;
	int i,n,T;
	scanf("%lld",&T);
	while(T--){
		s=0; 
		f1=1;
		f2=2;
		scanf("%lld",&n);
		if(n==1)
		s=f1;
		else if(n==2)
		s=f1+f2;
		else{
			s=f1+f2;
			for(i=3;i<=n;i++){
			 t=f1;
				f1=f2;
				f2+=t;
				s+=f2;
			}
		}
		printf("%lld\n",s);
	}
}

Double click to view unformatted code.


Back to problem 3695