View Code of Problem 48

#include<cstdio>
int main(){
	int n,a=2,b=1,temp;
	double ans;
	scanf("%d",&n);
	ans=a/b;
	for(int i=1;i<n;i++){
		temp=a;
		a=a+b;
		b=temp;
		ans=ans+double (a)/double (b);
	}
	printf("%.6lf",ans);
	return 0;
} 

Double click to view unformatted code.


Back to problem 48