Skip to content

Instantly share code, notes, and snippets.

@Radcliffe
Created June 27, 2023 22:15
Show Gist options
  • Save Radcliffe/e742408284cf1a9b71305343af715d8f to your computer and use it in GitHub Desktop.
Save Radcliffe/e742408284cf1a9b71305343af715d8f to your computer and use it in GitHub Desktop.
Counterexample to Euler's conjecture on sums of powers
"""
In 1769, Euler conjectured that it was impossible to express an nth power as the sum of fewer than
n nth powers of positive integers. For example, the sum of two cubes is not a cube, the sum of three
fourth powers is not a fourth power, and so on.
In 1966, L. J. Lander and T. R. Parkin found a counterexample: 27^5 + 84^5 + 110^5 + 133^5 = 144^5.
They performed a computer search using a CDC 6600. This was a massive computation for its time, but
it's easy for modern computers.
The following Python script searches for positive integer solutions to a^5 + b^5 + c^5 + d^5 = e^5
where a, b, c, d are less than 200. It should run in under a minute.
"""
from itertools import combinations_with_replacement
for a, b, c, d in combinations_with_replacement(range(1, 200), 4):
s = (a ** 5) + (b ** 5) + (c ** 5) + (d ** 5)
e = round(s ** 0.2)
if e ** 5 == s:
print(f"{a}^5 + {b}^5 + {c}^5 + {d}^5 = {e}^5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment