Mar-21-2019, 09:20 PM
I want to create a program, which will find pairs of amicable numbers lower than n.
I wrote a cod :
I wrote a cod :
def sumdiv(n): Sum = 0 for x in range(1, n // 2 + 1): if n % x == 0: Sum += x return Sum def amicable(n): for x in range(1, n): if sumdiv(sumadiv(x)) == x and sumdiv(x) != x: print(x, "and", sumdiv(x), "are amicable") m=int(input("Any natural number:")) print(amicable(m))I have problem, because I don't know why I get double pairs, for example (220,284) and (284,220).