Originally Posted by

**Quantum** Thanks!

Well how can we write a program for x

if x can be writen like

x= a^3 + b^3, where a and b is natural numbers? And then it shall return me a list of the numbers.

x is in (0,1,...,9999)

~~~~~~

Here's one way. Generate all cubes greater than 0 and less than 10^4. Put them in a list (sorted ascending). Then for each prime x, do a loop where you go through the list, subtracting the cube from x and seeing if the result is also in the list. Get out of the loop when the number you're subtracting is greater than floor(x/2).

For example you're going through all primes and you're currently at x = 23. Is 23-1=22 a perfect cube? No. Is 23-8=15 a perfect cube? No. And then you stop the loop because the next cube 27 is greater than floor(23/2). Thus 23 is not the sum of two cubes of natural numbers.

~~~~~~

Here's another way, probably a bit easier to write.

Do a loop within a loop:

Code:

for(i=1,i3=1;i3+i3<9998;i++,i3=i*i*i)
for(j=i,s=i3+j*j*j;s<9998;j++,s=i3+j*j*j) {
// check if s is prime here
}