Whenever you hear the word recursion, factorials or Towers of Hanoi are never far away. Well here they get mentioned, because we are not going to talk about these guys at all!
Iteration and recursion are in fact quite similar: they both loop until a certain condition is met.
As an exercise, I wanted to iterate a function and also turn that iteration into a recursive call.
To try something different and not that difficult I used Heron’s method,(an ancient Greek) which is a simple formula to calculate a square root of a number. This method is a special case of the Newton-Raphson method, developed tens of centuries later. See wiki if you want details. Hope the comments in the code are sufficient to understand it all.
And of course if I or you ever want to calculate a square root, use Math.Sqrt!
But if for example you want to find a cubic root of a polynomial, iteration is a way to go. This is also a demo that C# is suitable to use in math applications.