You are viewing a single comment's thread. Return to all comments →
easy sol
def divi_sum(n): r_sum=0 for i in range(1,int(n**0.5)+1): if n%i==0: r_sum+=i+n//i if int(n**0.5)==n**0.5: r_sum+=-int(n**0.5) r_sum+=-n return r_sum req_numbers={} our_sum=0 for i in range(1,10**5): req_numbers[i]=our_sum x=divi_sum(i) if x!=i and i==divi_sum(x): our_sum+=i for _ in range(int(input())): no=int(input()) print(req_numbers[no])
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #21: Amicable numbers
You are viewing a single comment's thread. Return to all comments →
easy sol