View Code of Problem 71

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

Double click to view unformatted code.


Back to problem 71