View Code of Problem 48

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

}

Double click to view unformatted code.


Back to problem 48