A recursive function repeatedly performs the same function in sequence and is usually accompanied by a starting value. Here is an example of a recursive function: f(x) = 2f(x-1)-1, where f(0)=5 In this case, f(0)=5 f(1)=2f(1-1)= 2f(0)-1= 2(5) - 1 = 10 - 1 = 9 F(2) = 2f( 2 - 1) - 1 = 2 f(1) - 1 = 2(9) - 1 = 18 - 1 = 17 and so on. Let’s apply a recursive function to a real-world situation. On his way to the office each workday (Monday through Friday), Darrell walks by a charitable foundation with a donation bucket se
et out front. He has decided that he wants to try to be more charitable, so starting next week, he plans to put $1 in the donation bucket every day he walks by. He has also estimated that he has already donated $23 to the foundation.
If x represents the number of weeks that Darrell has been making a donation, write a recursive function to represent the total amount he has donated. Explain your work.
The way this problem is worded, it cannot be answered. We don;t have enough info. We are asked for a function in terms of weeks, and we are told he will put money every day he walks by. We are not told he walks by every day of every week.
Ok thank you.
Darrell has already donated $23 to the foundation, so f(0) = $23. Because x represents the number of weeks, and Darrell is contributing $1 every day, Monday through Friday, he will contribute a total of $5 per week. So, the total amount donated will increase by $5 each week. Therefore, the recursive function will be f(x) = f(x - 1) + 5, where f($23).
@kweb2017 How do you know he puts in money Monday to Friday? Your problem did not state that.
Your problem stated "starting next week, he plans to put $1 in the donation bucket every day he walks by." We are not told he walks by every day of the week, or only Monday to Friday. The way the problem is stated, it seem to be a random thing. One week he could pass by the charity 3 times, the next week 5 times, another week 7 times, and another week no times at all. All we know is that when he does pass by, he will donate $1.
Also, if you do make the assumption that he walks by 5 days a week, then you meant to write this: "Therefore, the recursive function will be f(x) = f(x - 1) + 5, where f(0) = $23."
Join our real-time social learning platform and learn together with your friends!