View Code of Problem 48

#include<bits/stdc++.h>
using namespace std;

int main(){
	int n,up = 1,down = 1,tmp;
	cin>>n;
	double sum = 0;
	while(n--){
		tmp = down;
		down = up;
		up = up + tmp;
		sum+=(up*1.0/down);
	}
	printf("%.6f",sum);
	
	
	
	return 0;
}

Double click to view unformatted code.


Back to problem 48