r/computerscience • u/ShadowGuyinRealLife • May 22 '25
Discussion Why Are Recursive Functions Used?
Why are recursive functions sometimes used? If you want to do something multiple times, wouldn't a "while" loop in C and it's equivalent in other languages be enough? I am not talking about nested data structures like linked lists where each node has data and a pointed to another node, but a function which calls itself.
106
Upvotes
View all comments
Show parent comment
1
u/zenidam May 22 '25
This is a semantic disagreement. From an algorithmic perspective, yes, what you've shown implements a recursive function call. From a language design perspective, the code you've shown demonstrates neither functions nor recursive function calls, because you're using a language that offers neither feature. As I've said, my assumption all along is that OP was asking about the language feature, not the abstract algorithmic concept.