euler/python/e131.py

30 lines
572 B
Python
Raw Normal View History

2024-04-10 14:26:04 +02:00
from lib_prime import primes
def is_cube(n):
if n == 0:
return False
return round(n ** (1/3)) ** 3 == n
def euler_131():
r = 0
ps = primes(10**6)
minm = 1
for p in ps:
for m in range(minm, minm + 20):
n = m * m * m
x = n * n * n + n * n * p
if is_cube(x):
# print(p, n)
r += 1
minm = m
break
return r
if __name__ == "__main__":
solution = euler_131()
print("e131.py: " + str(solution))
assert(solution == 173)