Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- def amicable(n):
- def sum_factors(x):
- factors = 1
- total = 1
- for i in range(2, int(math.sqrt(x)) + 1):
- if(x%i == 0):
- total = total + i + x / i
- return total
- not_amicable = True
- test_amicable = n+1
- while not_amicable:
- test_amicable_partner = sum_factors(test_amicable)
- print(str(test_amicable_partner), str(sum_factors(test_amicable_partner)), str(test_amicable))
- if(sum_factors(test_amicable_partner) == test_amicable and test_amicable != test_amicable_partner):
- not_amicable = False
- test_amicable = test_amicable+1
- return test_amicable
- print (str(amicable(5)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement