View Code of Problem 48

#include<stdio.h>

int main()
{
    int n,i;
    double s=0;
    int a[12];
    a[1] = 1;
    a[2] = 2;
    scanf("%d",&n);
    for(i = 3; i < 12; i ++)
    {
        a[i] = a[i-2] + a[i-1];
    }
    for(i = 1; i <= n; i ++)
    {
        s = s + (double)a[i+1]/a[i];
    }
    printf("%.6lf\n",s);
    return 0;
}

Double click to view unformatted code.


Back to problem 48