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)
```

Expert's answer

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

Learn more about our help with Assignments: Python

## Comments

## Leave a comment