View Code of Problem 48

#include <stdio.h>
int main()
{
	int i,n,t;
  	scanf("%d",&n);
  	int a=2,b=1;
  	double x,sum=0.0;
  	while(n--)
        {
        	x=(double)a/b;
          	sum+=x;
          	t=a;
          	a=a+b;
          	b=t; 
        }
  	printf("%.6lf",sum);
}

Double click to view unformatted code.


Back to problem 48