R in general and especially loops are slow; slower than even Python. Making a function and applying it on a vector is a simple way to boost performance. Also recursion seems[1] to be faster than iteration.
Seeing the code in article, it can be that a part in that speedup is because R is used and not only of a better algorithm.
Seeing the code in article, it can be that a part in that speedup is because R is used and not only of a better algorithm.
[1]: https://predictivehacks.com/a-comparison-between-iteration-r...