View Code of Problem 23

#include<iostream>
using namespace std;
int main(){
	long long int a[100],m;
	while(cin>>m)
	{
		if(m!=0)
		{
			a[0]=1,a[1]=2;
			for(int i=2;i<=m;i++)
			{
				a[i]=a[i-1]+a[i-2];
				
			}
			cout<<a[m-1]<<endl;
			}
		}
		
	return 0;
}

Double click to view unformatted code.


Back to problem 23