Python Forum

Full Version: Refutation of the Euler hypothesis
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Problem with completing the task.
good time of day. In the process of learning programming in the Python environment, I encountered the problem of incorrect calculation. The problem being solved, the refutation of the Euler hypothesis. the following code is written for the solution:
for a in range(1, 150):
    for b in range(a, 150):
        for c in range(b, 150):
            for d in range(c, 150):
                e = ((a ** 5) + (b ** 5) + (c ** 5) + (d ** 5)) ** 0.2
                if e == int(e):
                    print(a, b, c, d, e, a + b + c + d + e)
if e != int(e):
    print('NO')
answer:
Output:
"NO"
The result of code execution, no solution. But this is not true. After studying this topic, the required numbers were found. Put numbers in the code:

a = 27
b = 84
c = 110
d = 133
e = (a ** 5) + (b ** 5) + (c ** 5) + (d ** 5)
a = e ** (1 / 5)
b = a ** 5
print(e, a, b )
answer:
Output:
61917364224 144.00000000000003 61917364224.00006
Wrong decision again, please explain what the error is. I can't figure out the problem without qualified help. Thank you in advance for an exhaustive answer!
Looks like the problem is with floating point approximation. Floating point in not precise, which is why you get 144.000...3.
You need to find a more reliable way to determine whether an integer is the fifth power of another integer. The rounding error of floating point numbers when you take the power 0.2 is the cause of your problem.