View Code of Problem 48

#include<stdio.h>
int main()
{
    int times;
    double result = 0;
    double fenzi = 2, fenmu = 1;
    scanf("%d",&times);
    for (int i = 0; i < times; ++i) {
        result += fenzi/fenmu ;
        int a = fenzi;
        fenzi += fenmu;
        fenmu = a;
    }
    printf("%6f",result);
}

Double click to view unformatted code.


Back to problem 48