Ask Question
5 August, 10:49

Def sum_divisors (n) : sum = 1 # Return the sum of all divisors of n, not including n x=int (n**0.5) for i in range (2, (x//1) + 1) : if n%i==0: sum=sum+i if n%i==0 and n/i!=i: sum=sum + (n/i) return sum print (sum_divisors (0)) # 0 print (sum_divisors (3)) # Should sum of 1 # 1 print (sum_divisors (36)) # Should sum of 1+2+3+4+6+9+12+18 # 55 print (sum_divisors (102)) # Should be sum of 2+3+6+17+34+51 # 114

+5
Answers (1)
  1. 5 August, 14:00
    0
    This is a python program that counts the number of divisors of a given number and calculates the sum of the divisors.

    Explanation:

    The first line defines a function "sum_divisors" with an argument "n". The square root of the argument is converted to integer and assigned to the variable "x", then a for loop is used to iterate through the range 2 to the calculated nth number of divisors in the argument. The return keyword returns the sum value.

    The function is called with several arguments and printed with the print function.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Def sum_divisors (n) : sum = 1 # Return the sum of all divisors of n, not including n x=int (n**0.5) for i in range (2, (x//1) + 1) : if ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers