Skip to the content.

Sums-of-Three-Cubes Solver

This repo contains a C program to list simple solutions (LSS) for the equation: x³ + y³ + z³ = n

Please note the sums of three cubes is a hard math problem, explained at: https://en.wikipedia.org/wiki/Sums_of_three_cubes and https://en.wikipedia.org/wiki/Diophantine_equation

image

🔧 Installation

Execute in a terminal window: (requires a C/C++ compiler only)

> git clone https://github.com/fleschutz/LSS  # or download and unzip the ZIP file (click green button)
> cd LSS
> cc -O3 -fopenmp main.c -o mode              # compiles with OpenMP API for multi-threading
> ./mode <NUMBER>                             # replace <NUMBER> by the mode number (see below)

Mode 1 - Solution for Given x,y,z

This mode calculates the result of: x³ + y³ + z³ for the given values of x, y, z. Note the following examples:

Mode 2 - No Solutions

This mode calculates and lists all non-existing solutions. No solution exists for: n equal 4 or 5 modulo 9.

./mode 2 returns: no_solutions.txt. This mode uses the listNoSolutions() function and took 0.116s on a Core i9.

Mode 3 - Trivial Solutions for Positive x,y,z

This mode calculates and lists all solutions for x >= 0, y >= 0, and z >= 0.

./mode 3 returns: solutions_for_positive_xyz.txt (for readability the file has been numerically sorted by executing: sort -g < infile > outfile). It uses the listSolutionsForPositiveXYZ() function and took 0.037s on a Core i9.

Mode 4 - Trivial Solutions for Negative z

This mode calculates and lists trivial solutions for z < 0.

./mode 4 returns: solutions_for_negative_z.txt. It uses the listSolutionsForNegativeZ() function and took 10s on a Core i9.

Mode 5 - Trivial Solutions for Negative y and z

This mode calculates and lists trivial solutions for y < 0 and z < 0.

./mode 5 returns: solutions_for_negative_yz.txt. It uses the listSolutionsForNegativeYZ() function and took 4h on a Core i9.

Mode 6 - All Trivial Solutions

This mode combines mode 2 + 3 + 4 + 5.

./mode 6 returns: trivial_solutions.txt and took 4h on a Core i9 CPU.

Mode 7 - Nontrivial Solutions

This mode calculates and lists nontrivial solutions for a given value range of x. The value range is defined by an exponent, e.g. exponent 6 means: x=[10^6..10^7]. It uses a ‘shotgun’ algorithm in the listNontrivialSolutions() function.

🏆 Nontrivial Solutions Already Solved

The following nontrivial solutions have already been solved in the past:

Want to verify the solutions? Use WolframAlpha or execute: ./mode 1 <x> <y> <z> (copy & paste recommended)

🏆 Nontrivial Solutions Currently Unsolved

The only remaining unsolved cases up to 1,000 are the following seven numbers:

Want to get famous? Just solve one of these numbers. May the force be with you 🖖

🤝 Contributing

This open source project is licensed under the CC0 license. All trademarks are the property of their respective owners.