View Code of Problem 48

#include <stdio.h>
#include <math.h>
int main()
{
	int a,b,n,c;
	double sum=0;
	a=1;b=2;
	scanf("%d",&n);
	while(n--){
		sum=sum+(1.0*b/a);
		c=b;
		b=a+b;
		a=c;
	}
	printf("%f\n",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 48