
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).


#lang racket
 
(define (cube x) (* x x x))
 
;floor of cubic root
(define (cubic-root x)
  (let ([aprox (inexact->exact (round (expt x (/ 1 3))))])
    (if (> (cube aprox) x)
        (- aprox 1)
        aprox)))
 
(let loop ([p 1] [n 1])
  (let ()
    (define pairs
      (for*/list ([j (in-range 1 (add1 (cubic-root (quotient n 2))))]
                  [k (in-value (cubic-root (- n (cube j))))]
                  #:when (= n (+ (cube j) (cube k))))
        (cons j k)))
    (if (>= (length pairs) 2)
      (begin
        (printf "~a: ~a" p n)
        (for ([pair (in-list pairs)])
          (printf " = ~a^3 + ~a^3" (car pair) (cdr pair)))
          (newline)
        (when (< p 25)
          (loop (add1 p) (add1 n))))
      (loop p (add1 n)))))