View Code of Problem 48

#include<stdio.h>
int main(){
	
	int n;
while(scanf("%d",&n)!=EOF){
			int i;
			double sum,l;
		double x=2;
			double y=1;
			double temp;
			for(i=1;i<n;i++){
				temp=x;
				x=x+y;
				y=temp;
				l=x/y;
				sum=sum+l	;
			}
			printf("%.6f\n",sum);
	}
	
	return 0;

}

Double click to view unformatted code.


Back to problem 48