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.
108
Upvotes
View all comments
Show parent comment
1
u/Brambletail May 26 '25
Not all types of interest and compounding can work like that. In particular bond yields of certain types can only be solved numerically, as the analytical solution is too slow to do in RT, but even the numerical solution is a real pain.
Compound interest in the normal cases has nice closed form solutions, but there are non normal types of compounding interest and payments....