View Code of Problem 23

#include<iostream>

#include<string>
using namespace std;
int main(){
	int a[100],m;
	while(cin>>m&&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