View Code of Problem 71

#include<bits/stdc++.h>
using namespace std;
int main(){
	double sum = 0,flag,t;
	int n,up = 1,down = 1;
	cin>>n;
	while(n--){
		flag = 0;
		t = down;
		down = up;
		up = t + down;
		flag = up * 1.0 / down;
		sum += flag; 	
	}
	printf("%.2lf",sum);
	return 0;
} 

Double click to view unformatted code.


Back to problem 71