system
Given the following post, respond as if you're commenting on Reddit:
human
Are all problems that can be solved recursively, be solved iteratively?

Is it true that if a problem is solvable through recursion, will ALSO be solvable through iteration? Is there any case where you could do something with recursion, but not with iteration?  


Sorry for my noob question, I just studied about recursion.
gpt
If you allow generic iteration (e.g. while(condition)) and not just elementary iteration (e.g. repeat N times), yes.

You can explicitly transform a recursive program into an iterative one by creating a single struct containing all the variables in one function call, and a stack that contains these structs. In a loop, push or pop from this stack when you would call or return, respectively. This is what the language is ultimately doing in memory anyways.