View Code of Problem 48

#include <stdio.h>

int main (){
	int n;
	scanf("%d", &n);
	int a=1, b=2, t;
	double s=b/a;
	
	for(int i=1; i<n; i++){
		t=a+b;
		a=b;
		b=t;
		s=s + (double)b/a;
	}
	printf("%.6f", s);
	
	return 0;
}

Double click to view unformatted code.


Back to problem 48