View Code of Problem 23

#include<iostream>

using namespace std;
int main()
{
	long long int m,d,x,temp,sum;
	while(cin>>m)
	{
		if(m!=0)
		{
			d=1,x=0,sum=0;
		for(int i=0;i<m;i++)
		{
			sum=d+x;
			temp=x;
			x=d;
			d=d+temp;
		}
		cout<<sum<<endl;
		}
		
	}
	return 0 ;
}

Double click to view unformatted code.


Back to problem 23