View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48