Skip to content

Commit

Permalink
add euler023 and euler058 solution
Browse files Browse the repository at this point in the history
  • Loading branch information
kailanefelix committed Oct 10, 2021
1 parent ebc9440 commit be78d0b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions euler0XX/euler023.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from numbertools import divisors

numbers = {*range(28124)}

abundant = {n for n in range(12, 28112) if sum(divisors(n)) > n}
abundant_sums = {a + b for a in abundant for b in abundant}

print(sum(numbers - abundant_sums))
18 changes: 18 additions & 0 deletions euler0XX/euler058.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from itertools import count
from numbers import is_prime

primes, total, number, step = 0, 0, 1, 2

for i in count():
for _ in range(4):
number = number + step

if is_prime(number):
primes = primes + 1
total = total + 1

step = step + 2

if primes / total < 0.1:
print(2 * i + 1)
break

0 comments on commit be78d0b

Please sign in to comment.