Edward A. answered 03/12/20
Math Tutor, Retired Computer Scientist and Technical Communicator
Alyssa,
Im eager to show you how, rather than just do it. So first, you’ve got to figure out what is the assignment is.
It looks like the assignment is:
1) write a function
2) use the function
So in more detail, “write the function”: I can give a hint about how to do that. I’d start by writing a really easy function that tells the height of one bounce. I’ll call it f(1). Then I’d figure how to change it into a function that handles b, any number of bounces.
Translate “A ball dropped from 20m bounces to a height of 5/8 of its previous height” into
f(1) = 20*(5/8)
so here’s a question: how would you write down the height after two bounces?
I can see an easy way and a tedious way. The tedious way is to calculate out 20*5/8, and then multiply by 5/8 for the second time.
f(1) = 20*5/8 = 100/8 = 25/2;
f(2) = 25/2 * 5/8 = (25*5)/(2*8) = 125/16
The easy way is to write down both 5/8 at once, and leave them alone.
f(2) = 20*(5/8)*(5/8)
So what would f(3) look like? Just multiply f(2) by 5/8
f(3) = 20*(5/8)*(5/8)*(5/8)
Do you see a pattern? Replace all those 5/8 s with one 5/8 and an exponent:
f(3) = 20*(5/8)3
So If b is the number of bounces, then
f(b) = 20*(5/8)b
Your function is complete. I hope I gave a hint about one of many ways to think about a recursive functions.
Now all you have to do is evaluate your function for 5 bounces.
f(5) = 20*(5/8)5
This is trivial with a calculator
(5/8)5 = .09536
f(5) = 20*(5/8)5 = 20*.09536 = 1.9072 m = 1.91 to nearest centimeter