Newtonβs method to calculate square roots is an example of an algorithm that repeats as long as it can improve the result. Itβs just a variation of our accumulator pattern. Many algorithms work this way and so require the use of indefinite iteration.
You may have studied this sequence in a math class and learned that the sum approaches but never reaches 2.0. That is true in theory. However, when we implement this summation in a program, we see something different.