Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Fill in the empty function so that it returns the sum of all the divisors of a number, without including it. A divisor is a number that divides into another without a remainder.

def sum_divisors(n):
    return sum([i for i in range(1, n)
                if n % i == 0])

print(sum_divisors(0))
print(sum_divisors(3)) # Should sum of 1
print(sum_divisors(36)) # Should sum of 1+2+3+4+6+9+12+18
print(sum_divisors(102)) # Should be sum of 2+3+6+17+34+51
Comment

PREVIOUS NEXT
Code Example
Python :: random.choices without repetition 
Python :: IndexError: list assignment index out of range 
Python :: function python 
Python :: python list max value 
Python :: matplotlib subplots share x axis 
Python :: search an array in python 
Python :: Fun & learn with python turtle 
Python :: Issue AttributeError: ‘numpy.ndarray’ object has no attribute ‘index’ 
Python :: count python 
Python :: python symbol 
Python :: Check if all values in list are greater than a certain number 
Python :: python matrix determinant without numpy 
Python :: initialize variable python 
Python :: naive bayes implementation in python 
Python :: best python programs 
Python :: circular linked list in python 
Python :: python3 delete file 
Python :: how to make a do while in python 
Python :: python sort list case insensitive 
Python :: matplotlib cheat sheet 
Python :: put grid behind matplotlib 
Python :: is microsoft teams free 
Python :: adding in python 
Python :: # get the largest number in a list and print its indexes 
Python :: selenium python element id 
Python :: python stack size 
Python :: utils/decorators.py", line 11, in __get__ raise AttributeError("This method is available only on the class, not on instances.") AttributeError: This method is available only on the class, not on instances. 
Python :: In is_lodes_form( : Missing id-axis pairings. 
Python :: pss signatures python 
Python :: Kernel Ridge et Hyperparameter cross validation sklearn 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =