Skip to content

Instantly share code, notes, and snippets.

@reox
Created June 18, 2014 19:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reox/933b64f84775b9a884da to your computer and use it in GitHub Desktop.
Save reox/933b64f84775b9a884da to your computer and use it in GitHub Desktop.
Print out the smallest numbers that are the sum of two cubes
import itertools
x = range(1, 20)
solutions = {}
for a, b in itertools.combinations(x, 2):
sol = a ** 2 + b ** 2
if sol in solutions:
print("Found a solutions: %d^2 + %d^2 = %d^2 + %d^2 = %d " % (a, b, solutions[sol][0], solutions[sol][1], sol))
solutions[sol] = (a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment