View Code of Problem 23

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

Double click to view unformatted code.


Back to problem 23