recursive functions(c++)

I want to present you a very short and easy for most of you recursive function, I think that if you understand this function you fully understand recursive functions, even tho this may seen way easier than a backtracking recursive function or a fill algorithm it isnt :

void f(int x)
{
if (x)
{
f(x - 1);
cout << x << ' ';
}
}

input : 3
output : 1 2 3
Topic archived. No new replies allowed.