View Code of Problem 3695

#include<bits/stdc++.h>
using namespace std; 
 
int main()
{
	int t, n;
	long long a[90], sum;
	cin >> t;
	while(t--)
	{
		sum = 0;
		cin >> n;
		memset(a, 0, sizeof(a));
		a[1] = 1;
		a[2] = 2;
		if(n >= 3)
		{
			for(int i = 3; i <= n; i++)
			{
				a[i] = a[i - 1] + a[i - 2];
			}
		}
		for(int i = 1; i <= n; i++)
		{
			sum += a[i];
		}
		cout << sum << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 3695