Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have known this from beginning that $1729$ is the smallest number expressible as the sum of two cubes in two different ways:

$$ 12^3 + 1^3 $$


$$ 10^3+9^3 $$

I am a Software Developer and if someone can tell me the logic to write a program for printing such types of number will be greatly helpful.

share|cite|improve this question

marked as duplicate by ᴡᴏʀᴅs, Jonas Meyer, Adam Hughes, JimmyK4542, Did Sep 9 '14 at 6:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I don´t understand what you mean by "next number", other number expressible as the sum of two cubes, or the smallest number greater than 1729 expressible as the sum of two cubes? – dwarandae Jan 30 '13 at 15:55
1 – MJD Jan 30 '13 at 17:21
I am also looking for an efficient program in Pari gp for finding numbers that are sums of three cubes in at least two ways. I do belive that programming efficiency, here, consists in writing first into RAM memory all the numbers which are sum of k cubes (k=2 or (k=3 in my case)) and then just find the numbers that coincide. But i do not know how to write such a program as i am self taught. – user55514 Jan 31 '13 at 14:20
Note that $1729$ is the smallest number expressible as a sum of two positive integer cubes in two different ways. While allowing a cube of zero doesn't introduce new solutions (case of Fermat's Last Thm.), allowing negative cubes does. For example $9^3 + (-1)^3 = 12^3 + (-10)^3$ is smaller than $1729$. – hardmath Jan 31 '13 at 14:36
+1 @hardmath . Noone knows this. – vikiiii Jan 31 '13 at 14:47

Check out: Taxi-cab numbers: sums of 2 cubes in more than 1 way

There are a couple of code snippets there for you to work with.

The sequence continues as follows:

$1729 = (1^3 + 12^3)$ or $(9^3 + 10^3)$

$4104 = (2^3 + 16^3)$ or $(9^3 + 15^3)$

$13832 = (2^3 + 24^3)$ or $(18^3 + 20^3)$

$20683 = (10^3 + 27^3)$ or $(19^3 + 24^3)$

$32832 = (4^3 + 32^3)$ or $(18^3 + 30^3)$

$39312 = (2^3 + 34^3)$ or $(15^3 + 33^3)$

$40033 = (9^3 + 34^3)$ or $(16^3 + 33^3)$

$46683 = (3^3 + 36^3)$ or $(27^3 + 30^3)$

$64232 = (17^3 + 39^3)$ or $(26^3 + 36^3)$

$65728 = (12^3 + 40^3)$ or $(31^3 + 33^3)$

After that you have: $110656, 110808, 134379, 149389, 165464, 171288, 195841, 216027, 216125, 262656$, etc.

You might also be interested in exploring:

$\bullet$ Diophantine Equation--3rd Powers

$\bullet$ Cubic Numbers

$\bullet$ Taxi Numbers in JavaScript


share|cite|improve this answer
Almost at a "nice answer" badge...+1 nudge closer ;-) – amWhy May 5 '13 at 0:20

This would be essentially solutions to the Diophantine equation, $a^3+b^3=c^3+d^3.$ Which I believe Euler solved for all rational numbers with :$(3a^2+5ab−5b^2)^3+(4a^2−4ab+6b^2)^3+(5a^2−5ab−3b^2)^3 = (6a^2−4ab+4b^2)^3$ This can be rewritten as $(A^2+7AB−9B^2)^3+(2A^2−4AB+12B^2)^3 = (2A^2+10B^2)^3+(A^2−9AB−B^2)^3$ with $a=A+B, b=A-2B.$

The solutions to all integer values only I don't believe has been found, but the solution to some integer values at least has been, and can be found in this paper by Marc Chamberland from 1999:

(This is the first answer I posted in this site so I'm not sure if my format for posting is correct, apologies if not)

share|cite|improve this answer

The bruteforce approach is simple.

Loop over integers $k$.

For $1\leq i<\frac k2$ check whether or not $i$ has a cubic root, and whether or not $k-i$ has a cubic root. If so, collect the pair.

When the collection of pairs has more than one pair, collect $k$.

Stop at some arbitrarily large integer, and print the collected $k$'s and the pairs collected for each.

There is probably a much better approach using heuristics though.

share|cite|improve this answer
Slightly less brute force: For $i=1,2,\ldots$ check whether or not $k-i^3$ has a cube root. Stop when $i^3>k/2$. – Harald Hanche-Olsen Jan 30 '13 at 15:56
Of course, in Haskell, you wouldn't need to stop anywhere. You can just calculate them all and print a finite subset. – akkkk Jan 30 '13 at 16:03

One logic to generate some taxi-cab numbers is to consider the equation


Now multiply this equation by $k^3$, this gives you $$1729k^3=(11k)^3+(k)^3=(10k)^3+(9k)^3.$$ Now put $k=1,2,3,4,....$ to obtain some terms of this sequence.

share|cite|improve this answer
Do you think I am a fool ?? – vikiiii Jan 30 '13 at 16:29
@vikiii You simply asked if there was logic to determine taxicab numbers. You didn't ask for an efficient algorithm. The two are very different, and the above approach could be suitable for some purposes. – apnorton Jan 30 '13 at 17:27
@vikiiii I know it's a pretty naive approach, but brute force( which is the other possible approach) is mentioned in other answers. And therefore I gave such a logic. This method is also used to prove that there exists infinite taxicab numbers. – sudeepdino008 Jan 30 '13 at 17:58
I am sorry I should not have told you this.Thanks for answering. I should have clearly mentioned that I want an efficent algorithm. – vikiiii Jan 31 '13 at 10:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.