summaryrefslogtreecommitdiff
path: root/day1/exercise/aliquot.py
blob: 7d5676c6cf37a5dcc556cdfce56b08045783423a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def aliquot(n):
    """returns the aliquot of a number which
    is defined as the sum of all the proper
    divisors of a number"""
    sum = 1
    i = 2

    while i * i < n: 
        if n % i == 0:
            sum += i + (n / i)
        i += 1
    if i*i == n: sum += i
    return sum

n = int(raw_input('Enter a number? '))
print aliquot(n)