View Code of Problem 71

#include<stdio.h>
#include<math.h>
main()
{
	int i,N;
	float k,sum,x,y,a,b,c,d;
	scanf("%d",&N);
	a=2;
	b=3;
	c=1;
	d=2;
	if(N==1)
	sum=a/c;
	else
	sum=a/c+b/d;
	for(i=3;i<=N;i++){
		x=a+b;
		y=c+d;
		a=b;
		b=x;
		c=d;
		d=y;
		sum+=x/y;
	}
	printf("%.2f",sum);
}

Double click to view unformatted code.


Back to problem 71