Question
def smallest_above_after_div(original, smallest, divisor): Find the smallest number above smallest you can get by repeatedly dividing original by divisor . For example: the smallest number
def smallest_above_after_div(original, smallest, divisor): Find the smallest number above smallest you can get by repeatedly dividing original by divisor. For example:
the smallest number above 100 you can get by dividing 500 repeatedly by 2 is 125 Start with 500, divide by 2 and get 250, divide by 2 and get 125, divide by 2 and get 62.5. 62.5 is too small, so 125 is the smallest above 100.
the smallest number above 5 you can get by dividing 125 repeatedly by 2 is 7.8125 Start with 125, divide by 2 and get 62.5, then 31.25, then 15.625, then 7.8125, then 3.90625 too small, 7.8125 is the smallest
the smallest number above 10 you can get by dividing 1000 repeatedly by 10 is 100 1000, 100, 10 too small, 100 is the smallest
4
Return value: a number (see above)
Assumptions:
o original and smallest will be positive numbers above 0
o divisor will be a positive number above 1
o original will be greater than smallest
Notes:
o Hint: Keep track of the last smallest value you computed that was valid (and dont lose that number when computing the next number).
Examples:
o smallest_above_after_div(500,100,2) 125.0 # see above explanation
o smallest_above_after_div(125,5,2) 7.8125 # see above explanation
o smallest_above_after_div(1000,10,10) 100.0 # see above explanation
o smallest_above_after_div(2,1,2) 2 # 2/2=1 (too small, ret. 2)
o smallest_above_after_div(1,0.25,2) 0.5 # 1/2=0.5, 0.5/2=0.25, ret. 0.5
pytthon3 language please
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