View Code of Problem 48

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,y,z=2,m=1;
	float sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		sum=sum+1.0*z/m;
		x=z+m;
		y=z;
		z=x;
		m=y;
	 } 
	printf("%.6f",sum);
	return 0;
 } 

Double click to view unformatted code.


Back to problem 48