Final answer:
The function rem(20, 5) will have 5 activations on the activation chain as it reduces 20 by intervals of 5 until reaching 0.
Step-by-step explanation:
The activation chain refers to the number of times a recursive function calls itself before reaching a base case. Here we have the recursive function rem() which calculates the remainder when a is divided by d. The main question is concerning the number of activations for rem(20, 5).
Since d is 5, and 20 is divisible by 5, the recursive calls will continue until a is less than d. We start with a = 20 and reduce a by d (which is 5) in each call. This results in the following activations:
- rem(20, 5) - which calls
- rem(15, 5) - which calls
- rem(10, 5) - which calls
- rem(5, 5) - which calls
- rem(0, 5) - which hits the base case a < d
Thus, there will be 5 activations on the activation chain for this example.