I don´t understand the change from a for loop to a recursive function

Hello there.

This topic was discussed at length over here: Replace Loops using Recursion -1 explanation

Hope this helps