View Code of Problem 71

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	double a=1;
	double b=2;
	double sum=0.0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		sum+=b/a;
		int temp;
		temp=a;
		a=b;
		b=b+temp;
	}
	printf("%.2f",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 71