Computer Science, asked by bhargavinamburi5, 11 months ago

What is g(24) - g(23), given the definition of g below?
def g(n):
s=0
for i in range(1,n+1):
if n%i == 0:
s = s+1
return(s)
by using python

Answers

Answered by 171ca002
0

Answer:

Explanation:

def g(n):

s=0

for i in range(1,n+1):

if n%i == 0:

s = s+1

Answered by lovingheart
1

According to the program, for loop runs from 1 to n + 1 and the value of s gets incremented each time whenever the given number comes as a multiple of i.

When n = 24 ie. g(24) gives S = 7,  

Here the number 24 is divided by 1, 2, 3, 6, 8, 12, 24

When n = 23 ie. g(223) gives S= 2

Since the number is prime number, 23 is divided only by 1 and 23, So

S = 2  

g(24) –g(23) gives 4 – 2 = 3

Similar questions