View Code of Problem 23

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

Double click to view unformatted code.


Back to problem 23