Originally Posted by Quantum
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:
// check if s is prime here