What is the value of h(231,8) for the function below?
def h(m,n):
ans = 0
while (m >= n):
(ans,m) = (ans+1,m-n)
return(ans)
1
Expert's answer
2018-08-22T05:12:58-0400
Answer is 28. Given function subtracts 8 from <m> variable on each iteration of while loop till <m> become smaller or equal then 8. On 28 iteration <m> becomes smaller then 8 and while loop is breaking.
Comments
Leave a comment