View Code of Problem 23

#include<stdio.h>
int main()
{
	int n,i;
	int a[90];
	a[0]=1;
	a[1]=2;
	while(scanf("%d",&n)!=EOF)
	{
		if(n==0)
			break;
		for(i=2;i<n;i++)
		{
			a[i]=a[i-1]+a[i-2];
		}
		printf("%d",a[n-1]);
	}
}

Double click to view unformatted code.


Back to problem 23