Computer Science, asked by rudraaniket0, 17 days ago

2) What is h(60)-h(45), given the definition of h below?
def h(n):
S = 0
for i in range(2,n):
if n%i == 0 :
S = S+i
return(s)​

Answers

Answered by mukkuchandrasekharre
0

Answer:

75

Explanation:

sun of factors of 60 [2,3,4,5,6,10,15,20,30,45]=107

sun of factors of 45[ 3, 5, 9, 15]=32

107-32=75

Answered by rishita29gupta
2

Answer:

def h(n):

   s = 0

   for i in range(2,n):

       if n%i == 0:

          s = s+i

   return(s)

h(60)-h(45)

Output:-75

Explanation:

for, h(60)

i in range(2,60) i.e 2,3,4, till ,59

n%i==0 means 60%i==0 i.e it comprises factors of 60 in range 2 to 59

{2,3,4,5,6,10,12,15,20,30} (exclude 60 due to range)

if 60 is div. by 2 then s become 0+2=2 (s=s+i initially s=0, i=2)

if 60 is div. by 3 then s become 2+3=5

if 60 is div. by 4 then s become 5+4=9

...

similarly all and final value of s=2+3+4+5+6+10+12+15+20+30=107

similarly for 45

{3,5,9,15}

s=3+5+9+15=32

therefore, h(60)-h45)= 107-32=75Ans.

Similar questions