Created
July 26, 2021 12:55
-
-
Save igorvanloo/a9f9d9e6979a83c536dfe629deb287e3 to your computer and use it in GitHub Desktop.
Problem 700
This file contains hidden or 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
def compute(): | |
eulercoins = [1504170715041707] | |
current_eulercoin = 1504170715041707 | |
inv = pow(1504170715041707, -1, 4503599627370517) | |
n = 2 | |
while True: | |
number = 1504170715041707*n % 4503599627370517 #Search downwards | |
if number < current_eulercoin: | |
current_eulercoin = number | |
eulercoins.append(number) | |
print(n, number) | |
if current_eulercoin == 15806432: #Our switch strategy case | |
new_curr_eulercoin = 1 | |
curr_max = 4503599627370517 | |
while new_curr_eulercoin != 15806432: | |
number = (inv*new_curr_eulercoin) % 4503599627370517 #Search upwards | |
if number < curr_max: | |
curr_max = number | |
eulercoins.append(new_curr_eulercoin) | |
print(number, new_curr_eulercoin) | |
new_curr_eulercoin += 1 | |
break | |
n += 1 | |
return sum(eulercoins) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment