From b0cccc97ab193fd4de15f7f4cbba61bb6e9c6620 Mon Sep 17 00:00:00 2001 From: Felix Martin Date: Fri, 9 Apr 2021 23:44:28 -0400 Subject: [PATCH] Solve problem 87 --- python/e086.py | 9 +++++++++ python/e087.py | 30 ++++++++++++++++++++++++++++++ python/lib_create_templates.py | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 python/e086.py create mode 100644 python/e087.py diff --git a/python/e086.py b/python/e086.py new file mode 100644 index 0000000..6bbf48b --- /dev/null +++ b/python/e086.py @@ -0,0 +1,9 @@ + +def euler_086(): + return 0 + + +if __name__ == "__main__": + solution = euler_086() + print("e086.py: " + str(solution)) + assert(solution == 0) diff --git a/python/e087.py b/python/e087.py new file mode 100644 index 0000000..61ddca9 --- /dev/null +++ b/python/e087.py @@ -0,0 +1,30 @@ +from lib_prime import primes + + +def euler_087(): + n_max = 50000000 + ps = primes(10**5) + found = set() + c = 0 + for p4 in ps: + p4s = p4 ** 4 + if p4 > n_max: + break + for p3 in ps: + p3s = p3 ** 3 + if p4s + p3s > n_max: + break + for p2 in ps: + p2s = p2 ** 2 + p = p2s + p3s + p4s + if p < n_max and not p in found: + c += 1 + found.add(p) + return c + + +if __name__ == "__main__": + solution = euler_087() + print("e087.py: " + str(solution)) + assert(solution == 1097343) +# diff --git a/python/lib_create_templates.py b/python/lib_create_templates.py index 9e37fb6..cbac898 100644 --- a/python/lib_create_templates.py +++ b/python/lib_create_templates.py @@ -1,5 +1,5 @@ -FROM = 85 -TILL = 85 +FROM = 88 +TILL = 90 template = """ def euler_XXX():