According to Wikipedia, and also a very common definition of a recursive function found in several books, "functions that call themselves from within their own code". I agree that this solves the problem for most of what I think recursive functions are, but, suppose you have the following "iterative" code written in C:
int foo(){
return 2;
}
The unique pourpose of this function is to compute the value "2". Can we say this is also a "recursive" function? Saying it only relies in a base case. I can see the function isn't calling itself in their body, even though, I can't find a way to compute it in another way, using the self-calling part.
Besides, I'm aware of the fact that every iterative function has a recursive implementation, so, in this case this function does have the same implementation for the iterative and for the recursive view?
return true ? 2 : foo();
in C. $\endgroup$ – beroal Jun 15 '20 at 20:16