
A   taxicab number   (the definition that is being used here)   is a positive integer that can be expressed as the sum of two positive cubes in more than one way.



The first taxicab number is   1729,   which is:

 13   +   123       and also
 93   +   103.


Taxicab numbers are also known as:

   taxi numbers
   taxi-cab numbers
   taxi cab numbers
   Hardy-Ramanujan numbers


Task

 Compute and display the lowest 25 taxicab numbers (in numeric order, and in a human-readable format).
 For each of the taxicab numbers, show the number as well as it's constituent cubes.


Extra credit
 Show the 2,000th taxicab number, and a half dozen more


See also

 A001235: taxicab numbers on The On-Line Encyclopedia of Integer Sequences.
 Hardy-Ramanujan Number on MathWorld.
 taxicab number on MathWorld.
 taxicab number on Wikipedia   (includes the story on how taxi-cab numbers came to be called).


 
# syntax: GAWK -f TAXICAB_NUMBERS.AWK
BEGIN {
    stop = 99
    for (a=1; a<=stop; a++) {
      for (b=1; b<=stop; b++) {
        n1 = a^3 + b^3
        for (c=1; c<=stop; c++) {
          if (a == c) { continue }
          for (d=1; d<=stop; d++) {
            n2 = c^3 + d^3
            if (n1 == n2 && (a != d || b != c)) {
              if (n1 in arr) { continue }
              arr[n1] = sprintf("%7d = %2d^3 + %2d^3 = %2d^3 + %2d^3",n1,a,b,c,d)
            }
          }
        }
      }
    }
    PROCINFO["sorted_in"] = "@ind_num_asc"
    for (i in arr) {
      if (++count <= 25) {
        printf("%2d: %s\n",count,arr[i])
      }
    }
    printf("\nThere are %d taxicab numbers using bounds of %d\n",length(arr),stop)
    exit(0)
}
 