Question: Write code for a function named formula, that takes an integer x and returns an integer. The function must use recursion to calculate the return
Write code for a function named formula, that takes an integer x and returns an integer. The function must use recursion to calculate the return value as follows:
For all x >= 0, formula(0) is 4, where x is 0. (base case) formula(x) is 2x + formula(x-1) where x > 0. (recursive case)
Do not write any code to get input or show output.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
