#include <cstdlib>
#include <iostream>
using namespace std;
int myFunction(int n)
{
    int x;
    if (n==1 || n==2)
       x = 1;
    else
        x = myFunction(n-2) + myFunction(n-1);
    return x;
}
int main(int argc, char *argv[])
{
    int n,a;
    n = 7;
    a = myFunction(n);
    cout << "x is: " << a; 
    system("PAUSE");
    return EXIT_SUCCESS;
}
The output to this is "x is: 13". How do I get x = 13 when I do n = 7? It seems that the function repeats some number of times until x=1.
 
     
    