View Code of Problem 23

#include<iostream>
using namespace std;
int main(){
	int m;
	while(cin>>m&&m){
		int a[9999];
		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;
} 
//1 0+1 1
//2 1+1 2
//3 2+1 3
//4 3+2 5
//5 5+3 8
 

Double click to view unformatted code.


Back to problem 23