Now you have seen two recursive definitions, one for power_of_2
and
one for rabbits
. Many mathematically oriented programmers
prefer
such recursive definitions to iterative definitions, when both are
possible, believing that there is inherent elegance in defining a function
partly in terms of itself.
Other, practically oriented programmers dislike recursive definitions for one or both of two reasons: first, the recursive approach usually produces slower programs, because each function call takes time; and second, the recursive approach may have problems with large arguments, because the number of function calls in a recursive chain of calls is usually limited to a few hundred. Recursion aficionados counter by creating compilers that handle certain recursive functions in sophisticated ways that avoid such limits. These aficionados generally do not work on C compilers, however.