In the last article we dealt with recursions and considered the faculty as an example of recursion:
It turned out that the use of recursions with a high recursion depth can lead to an impairment of computer performance.
One approach to solve this is the bottom-up approach. Instead of recursive programming, a while loop is used, which multiplies the numbers from 1 to n:
As we can see, it is not always clear which method of repetition (while, for, recursion) makes sense in which case. Often you can use several methods, but solving the problem with one method may be more difficult than with the other.