View Code of Problem 48

#include<stdio.h>
int main()
{
	int n;
	while (scanf("%d",&n)!=EOF)
	{
		int a = 1, b = 2;
		double sum = 0;
		for (int i = 1; i <= n; i++)
		{
			sum += (b / (a*1.0));
			int t = b;
			b = a + t;
			a = t;
		}
			printf("%.6lf\n", sum);
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 48