Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Programming Languages 12th International Symposium Dbpl 2009 Lyon France August 2009 Proceedings Lncs 5708

Authors: Philippa Gardner ,Floris Geerts

2009th Edition

3642037925, 978-3642037924

More Books

Students also viewed these Databases questions