View Code of Problem 48

#include<stdio.h>
#include<math.h>
#include<string.h>
int main()
{
	int i,n;
	double a=2,temp,b=1,s=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		s=s+a/b;
		temp=a;
		a=a+b;
		
		b=temp;
	}
	printf("%.6lf\n",s);
  return 0;
}

Double click to view unformatted code.


Back to problem 48