View Code of Problem 23

#include<bits/stdc++.h>
using namespace std;

long long fi(int n){
    if (n==1)
        return 1;
    else if (n==2)
        return 2;
    else
        return fi(n-1)+fi(n-2);
}

int main() {
    int m;
    while (cin>>m,m){
        cout<<fi(m)<<endl;
    }

    return 0;
}

Double click to view unformatted code.


Back to problem 23