#The function gets some argument n - Let's set n is 5 for example.
def h(n):
s = 0
#Then the function creates a sequence of numbers from 1 to n with range(1, n+1) function (result will be 1, 2, 3, 4, 5 in our case) and iterates over each of this numbers.
for i in range(2,n):
#If remainder of dividing n to the number from the sequence greater then 0, variable s increments by 1.
if n%i == 0:
s = s+i
# For our sequence we gets remainders 0, 1, 2, 1, 0 and variable s equal to 3. When the iteration complete, function returns s value.
return(s)
Comments
Leave a comment