View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48