September 2026
1051 pages
35h 4m
English
Python allows the programmer to write recursive functions, which are functions that call themselves. The called function calls itself until a termination condition ends this otherwise-endless recursion. The number of nested function calls is referred to as recursion depth and is limited to a certain value by the runtime environment.
In the following example, a recursive function has been written for calculating the factorial of an integer:
def fac(n): if n > 1: return fac(n - 1) * n else: return 1
The purpose of this section isn’t to fully introduce the subject of recursion. Instead, we simply want to give you a brief overview here. If you don't understand the example right away, don't feel discouraged: You can program ...
Read now
Unlock full access