View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48