View Code of Problem 71

#include<stdio.h>
int main() {
	int n,i,t;
	float sum=0.0,a=2.0,b=1.0;

	scanf("%d",&n);

	for(i=1; i<=n; i++) {
		sum=sum+a/b;
		t=a;
		a=t+b;
		b=t;
	}
	printf("%.2f\n",sum);
	return 0;
}

Double click to view unformatted code.


Back to problem 71