Question
A frog falls down a well that is numfeet feet deep and is trying to get out. On the frog's first jump he leaps 1
A frog falls down a well that is numfeet feet deep and is trying to get out. On the frog's first jump he leaps 1 foot, and on each successive jump he doubles his jump distance. Unfortunately, after making each jump he slips one foot down the well. For example, his first jumps will look like this:
Jump | Jump Distance | Distance Slipped | New Height |
1 | 1 | 1 | 0 |
2 | 2 | 1 | 1 |
3 | 4 | 1 | 4 |
The frog gets out of the well once he makes it as high as the top. For example, if the well were 1 foot deep, then the frog would make it out on his first jump. (Remember, the frog may make it out of the well before he slips back!)
Write a function that takes numfeet as a parameter, and returns the number of jumps the frog makes before getting out of the well. Your function should do no I/O and not call any other functions unless you write them! def numJump(numfeet):
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started