Created
July 21, 2021 15:46
-
-
Save igorvanloo/63373b42130087677c8a2a9f3add0284 to your computer and use it in GitHub Desktop.
Problem 23
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 Divisors(x): | |
| divisors = [] | |
| for i in range(1,int(math.sqrt(x))+1): | |
| if x % i == 0: | |
| divisors.append(i) | |
| if i != int(x/i): | |
| divisors.append(int(x/i)) | |
| divisors.remove(x) | |
| return sum(set(divisors)) | |
| def compute(): | |
| abundantnums = [] | |
| for x in range(1,28123 + 1): | |
| if x < Divisors(x): | |
| abundantnums.append(x) | |
| array = [True]*28124 | |
| for y in range(len(abundantnums)): | |
| for z in range(y, len(abundantnums)): | |
| if abundantnums[y]+abundantnums[z] < 28124: | |
| array[abundantnums[y]+abundantnums[z]] = False | |
| return sum([i for i in range(len(array)) if array[i]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment