View Code of Problem 48

#include <stdio.h>
int main(int argc, char *argv[])
{
	int n;
	double sum=0,a=2.0,b=1.0,t=0;
	scanf("%d",&n);
	while(n--){
		sum=sum+a/b;
		t=a;
		a=a+b;
		b=t;
	}
	printf("%.6lf",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 48