Created
January 18, 2018 09:23
-
-
Save adamcheasley/101441a0b3bcd3c5bae50f7e88ccd331 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def sum_of_proper_divisors(n): | |
divisor_sum = 1 | |
for x in range(2, int((n / 2) + 1)): | |
if n % x == 0: | |
divisor_sum += x | |
return divisor_sum | |
n = 4259751 | |
while True: | |
sum_of_n_divisors = sum_of_proper_divisors(n) | |
if sum_of_proper_divisors( | |
sum_of_n_divisors) == n and n < sum_of_n_divisors: | |
try: | |
requests.post( | |
'https://safe-eyrie-79589.herokuapp.com/', | |
data={'key':'sqo3rZsduoeT4GGbMVbWuVpscp', 'lower': n, 'higher': sum_of_n_divisors}, | |
) | |
except: | |
print("error posting data") | |
print("found amicable pair {}, {}".format(n, sum_of_n_divisors)) | |
n += 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment