View Code of Problem 48

#include<stdio.h>
int main(){
double s=0 , a=2,b=1;
int n;
scanf("%d",&n);
for (int i = 0; i < n; ++i) {
printf("%.f/%.f%c",a,b,i<n-1?'+':'=');
s+=a/b;
a=a+b;
b=a-b;
}
printf("%.2f\n",s);
}

Double click to view unformatted code.


Back to problem 48