View Code of Problem 48

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double a=1,b=2;
	double tmp,sum=0;
	cin>>n;
	while(n--){
		sum=sum+b/a;
		tmp=b; 
		b=a+b;
		a=tmp;
	}
	printf("%.6lf\n",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 48