Python Forum
Refutation of the Euler hypothesis
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Refutation of the Euler hypothesis
#1
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!
Gribouillis write Jun-24-2023, 07:39 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button

Attached Files

.py   main.py (Size: 322 bytes / Downloads: 124)
Reply
#2
Looks like the problem is with floating point approximation. Floating point in not precise, which is why you get 144.000...3.
Reply
#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.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020