View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48