View Code of Problem 3695

#include<stdio.h>
#include<string.h>
int F(int x) {
    if (x==1)
    {
        return 1;
    }
    else if (x==2)
    {
        return 2;
    }
    else
    {
        return F(x - 1) + F(x - 2);
    }
}
int main() {
    int n;
    scanf("%d",&n);
    while (n--)
    {
        int count = 0;
        int a;
        scanf("%d",&a);
        for (int i = 1; i <= a; i++)
        {
            int num = F(i);
            count += num;
        }
        printf("%d\n", count);
    }


    return 0;

}

Double click to view unformatted code.


Back to problem 3695