View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48