View Code of Problem 23

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int m,i;
	while(scanf("%d",&m)!=EOF){
	if(m==0){
		break;
	}
	long int a[1000]={0,1,2};
	for(i=3;i<=m;i++){
		a[i]=a[i-1]+a[i-2];
	}
	printf("%ld\n",a[m]);
	}
}

Double click to view unformatted code.


Back to problem 23