#include<iostream> #include<cstring> using namespace std; int main(){ double sum = 0,up = 1,down = 1,t; int n; scanf("%d",&n); for(int i = 0;i<n;i++){ t = down; down = up; up = up + t; sum = sum + up / down; } printf("%.6lf",sum); return 0; } |
Double click to view unformatted code.