Python abundant, deficient, or perfect number
<pre><code>def classify(numb):
    i=1
    j=1
    sum=0
    for i in range(numb):
        for j in range(numb):
            if (i*j==numb):
                sum=sum+i
                sum=sum+j
            if sum&gt;numb:
                print("The value",numb,"is an abundant number.")
            elif sum&lt;numb:
                print("The value",numb,"is a deficient number.")
            else:
                print("The value",numb,"is a perfect number.")
            break
    return "perfect"
</code></pre>

<p>The code takes a number(numb) and classifies it as an abundant, deficient or perfect number. My output is screwy and only works for certain numbers. I assume it's indentation or the break that I am using incorrectly. Help would be greatly appreciated. </p>

<p>Somewhere you are misinterpreting something. As is you are printing what kind the number is, as many times as the value of the number. I might be missing something but anyway. </p>

<p>The sum of proper divisors can be found naively through using modulo </p>

<pre><code>def classify1(num):
    div_sum = sum(x for x in range(1, num) if num % x == 0)
    kind = ""
    if div_sum &lt; num:
        kind = "deficient"
    elif div_sum &gt; num:
        kind = "abundant"
    else:
        kind = "perfect"
    print("{} is a {} number".format(num, kind))
</code></pre>

<hr>

<p>but for big numbers or maybe numbers this will take a long time. So I welcome you to the divisor function. I just dump it and explain it. </p>

<pre><code>def mark(li: list, x: int):

    for i in range(2*x, len(li), x):
        li[i] = False
    return li


def sieve(lim: int):
    li = [True] * lim
    li[0] = li[1] = 0
    for x in range(2, int(lim ** 0.5) + 1):
        if x:
            li = mark(li, x)
    return [2]+[x for x in range(3, lim, 2) if li[x]]


def factor(num):

    divs = list()
    for prime in primes:
        if prime * prime &gt; num:
            if num &gt; 1:
                divs += [num]
            return divs
        while num % prime == 0:
            num //= prime
            divs += [prime]
    else:
        return divs


def divisors_sum(num):
    """
    Function that implements a geometric series to generate the sum of the
     divisors, but it is not the divisor function since removing original
     number.
    """
    divs = factor(num)
    div_sum, s = 1, 0
    for div in set(divs):
        s = 0
        for exponent in range(0, divs.count(div) + 1):
            s += div ** exponent
        div_sum *= s
    else:
        return div_sum - num


primes = sieve(limit)
</code></pre>

<p>but.. there is not much explaining due, first prime factor the numbers, and use the divisor function to get the proper divisors sum. That is it. However the speed up is ridiculously much fast. This might seem to over kill the problem but it is just that much more cooler and faster. </p>

python for-loop indentation break