Answer to Question #157935 in Python for Prathi

Question #157935

What is h(41)-h(40), given the definition of h below?

def h(n):
    s = 0
    for i in range(1,n+1):
        if n%i > 0:
           s = s+1
    return(s)
1
Expert's answer
2021-01-24T11:09:49-0500

The function finds the total number of non divisors in the range 1 to 41, that the given number has. For example 41 has 2 divisors(1,41), therefore 39 non divisors. The function h(41) returns 39. The function h(40) returns 32, divisors of 40, (1,2,4,5,8,10,20,40), non divisors therefore are 32.

h(41)-h(40) = 39-32 = 7


Ans. 7


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS