1142 - 分数序列前n项之和

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