Ashley has 100 books that she wants to give away at the rate of n books per week. Write a recursive function that represents the number of books Ashley has at any time. The recursive function that gives the number of books Ashley has at any time is
Let B(w) be the number of books that Ashley has in week w and specify w >= 0. A recursive function has two parts: 1. A simple base case (or cases)—a terminating scenario that does not use recursion to produce an answer 2. A set of rules that reduce all other cases toward the base case So, for Ashley, the number of books at any time is: 1. If w = 0 then B(w) = 100 2. If w > 0 then B(w) = MAX( B(w-1) – n, 0 ) [note: B(w) cannot be negative] Hope This helps Hun :)
help pleace @Michele_Laino
Join our real-time social learning platform and learn together with your friends!