The laws of recursion are:
- Change at least one argument while recurring. The arguments must be changed to be closer to termination
- The changing argument must be tested in the termination condition
(from The Little Schemer, a most excellent book about recursion)
y1-1 in this line takes care of rule 1:
and this line takes care of rule 2:
Each time the function calls itself, it decrements y1. When y1 reaches 1, the function is done.
(You may also note that if y1 is less than 1, the function will not work correctly: mathematically, it will loop forever, but in actuality, on most architectures y1 will underflow, become positive, and eventually reach 1, at which point the function will return a wildly incorrect result).
It would be instructive to execute this function in your head--pretend to be the computer. Call the function with x1 = 2 and y1 = 3 and step through it, doing everything the computer would do. Use a pencil and a piece of paper to keep track of the values of x1 and y1, remembering that each recursive call creates a new stack frame with new, independent values of x1 and y2; each return destroys the most recent stack frame and restores x1 and x2 to the values they had in the previous stack frame.