View Code of Problem 48

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

int main()
{
	int n;
	double a=2,b=1,temp,sum=0;
	scanf("%d",&n);
	while(n--)
	{
		sum+=a/b;
		temp=a;
		a=a+b;
		b=temp;
	}
	printf("%.6f",sum);
	
} 

Double click to view unformatted code.


Back to problem 48