View Code of Problem 48

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

Double click to view unformatted code.


Back to problem 48