View Code of Problem 48

#include <stdio.h>
int main() {
	int n;
	scanf("%d",&n);
	int i,x,y;
	float sum=2;
	x=2;
	y=1;
	if(n>=1&&n<=10) {
		for(i=2; i<=n; i++) {
			int tmp=y;
			y=x;
			x=tmp+x;
			sum=sum+(x*1.0)/y;
		}
		printf("%.6f",sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 48