View Code of Problem 71

#include<bits/stdc++.h>
using namespace std;
int main()
{
	double a=2, b=1;
	int n;
	cin >> n;
	double t=0;
	double temp;
	while (n--) {
		t += a / b;
		temp = a;
		a = a + b;
		b = temp;
	}
	cout <<fixed<<setprecision(2)<< t;
}

Double click to view unformatted code.


Back to problem 71