View Code of Problem 48

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


}

Double click to view unformatted code.


Back to problem 48