View Code of Problem 48

#include<stdio.h>
void hanshu(int n){
    double fz=2.0;double fm=1.0;
    double sum=0.0;
    double temp=0.0;
    for(int i=0;i<n;i++){
        sum+=fz/fm;
        temp=fz;
        fz+=fm;
        fm=temp;
    }
    printf("%.6f",sum);
}
int main(){
    int n;
    scanf("%d",&n);
    hanshu(n);

}

Double click to view unformatted code.


Back to problem 48