0
def divisor_sum(num):
    total=0
    for x in range(1, num):
        if num % x == 0:
           total+=x
    return total
value = 0
total = 0
for i in range(0,10001):
    value = divisor_sum(i)
    if i != value and divisor_sum(value) == i:
        print(i,value)
        total+=i

print(total)

this code does not cause error in line 11 (if i != value and divisor_sum(value) == i:)

def divisor_sum(num):
    total=0
    for x in range(1, num):
        if num % x == 0:
           total+=x
    return total
value = 0
total = 0
for i in range(0,10001):
    value = divisor_sum(i)
    if i is not value and divisor_sum(value) == i:
        print(i,value)
        total+=i

print(total)

if i is not value and divisor_sum(value) == i: but the code cause 8128 8128 why do this when use 'is not'

  • why are you using `is` to compare equality? That isn't what `is` does. It compares *identitiy* – juanpa.arrivillaga May 07 '20 at 03:04
  • @juanpa.arrivillaga it's not at all intuitively obvious that two integers with a value of 8128 would not have the same identity. It might have been a mistake for Python to use keywords that have meanings that don't map to common English meanings. – Mark Ransom May 07 '20 at 03:27

0 Answers0