Computer Science, asked by hritik627, 10 months ago

For what value of n would g(637,n) return 4?
def g(m,n):
res = 0
while m >= n:
(res,m) = (res+1,m/n)
return(res)

Answers

Answered by monica789412
3

value of n g(637,n) return 4 in the following way.

Explanation:

def g(m,n):

 res=0

while m>=n:

 (res,m)=(res+1,m/n)

return(res)

It would seem you need to run the loop four times. Each time you divide by 'n'.

That gives two conditions:

i) you want 'n' such that m/n⁴ <= n

ii) you want 'n' such that m/n³ > n

The first condition says you want to break after the fourth iteration. The second condition says you want it not yet to break after the third iteration.

That confines the values of 'n' to:

ceil(637^(1/5)) <= n <= floor(637^(1/4))

which is: 4 <= n <= 5, assuming that you want 'n' to be of integral type.

To learn more about this :

https://brainly.in/question/15229557

Similar questions