View Code of Problem 48

#include<stdio.h>
int main(){
	double sum=0;
	int a=2,b=1,c,n,i;

	scanf("%d",&n);

	for(i=1;i<=n;i++){
		sum+=(1.0*a/b);
		c = b;
		b = a;
		a = a+c;
	}

	printf("%.6f", sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 48