View Code of Problem 23

#include<stdio.h>
int main(){
	int m;
	while(scanf("%d",&m)!=EOF){
		if(m==0)
		break;
		else{
			int i,temp,a=1,b=0,sum=0;
			for(i=0;i<m;i++){
				if(i==0)
				temp=0;
				else
				temp=a;
				a=b+a;
				b=temp;
				sum=a+b;
			}
			printf("%d\n",sum);
		}
	}
}

Double click to view unformatted code.


Back to problem 23