#include<stdio.h> #include<string.h> int main() { double sum=0,a=2,b=1,t; int count,n=0; scanf("%d",&count); while(n<count) { sum+=a/b; t=a+b; b=a; a=t; n++; } printf("%.6lf",sum); }
Double click to view unformatted code.