Skip to main content

Command Palette

Search for a command to run...

Project Euler Problem#21

Published
1 min readView as Markdown
#python program to sum of all the amicable numbers under 10000
def sum_divisor(num):
    list1=[]
    for i in range (1,num):
        if num%i==0:
            list1.append(i)
    sum=0
    for i in list1:
        sum+=i
    return sum
sum=0
for i in range(1,10000):
    a=sum_divisor(i)
    b=sum_divisor(a)
    if i==b and a!=i:
        sum+=i
print(sum) #31626

More from this blog

Untitled Publication

42 posts