View Code of Problem 23

#include <stdio.h>
#include <string.h>
#include <math.h>
int dg(int n){
	if(n==1)
		return 1;
	else if(n==2)
		return 2;
	else
		return dg(n-1)+dg(n-2);
	
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF&&n!=0){
		printf("%d\n",dg(n));
	}
	
}

Double click to view unformatted code.


Back to problem 23