View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48