View Code of Problem 48

#include<iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <cmath>
using namespace std;
#pragma warning(disable:4996)


int main() {
	int n;
	scanf("%d", &n);
	int a,b;
	a = 1;
	b = 2;
	int temp;
	double m = 0;
	for (int i = 0; i < n; i++) {
		m += (double)b / a;
		temp = b;
		b = a + b;
		a = temp;
	}
	printf("%lf", m);
	return 0;
}	

Double click to view unformatted code.


Back to problem 48