title: Find the Hardy–Ramanujan number using R5RS scheme. Please suggest improvements in idiom and calculations.
body: <blockquote>
    <p>I remember once going to see
    [Srinivasa Ramanujan] when he was ill
    at Putney. I had ridden in taxi cab
    number 1729 and remarked that the
    number seemed to me rather a dull one,
    and that I hoped it was not an
    unfavorable omen. "No," he replied,
    "it is a very interesting number; it
    is the smallest number expressible as
    the sum of two cubes in two different
    ways." [G. H. Hardy as told in <a href="http://en.wikipedia.org/wiki/1729_%28number%29" rel="nofollow">"1729
    (number)"</a>]</p>
  </blockquote>
  
  <p>In <a href="http://www.forbes.com/2009/02/06/math-archimedes-churchill-opinions-contributors_0207_joseph_tartakovsky.html" rel="nofollow">"Math Wrath"</a> Joseph Tartakovsky says about this feat, "So what?
  Give me two minutes and my calculator watch, and I'll do the same
  without exerting any little gray cells." I don't know how
  Mr. Tartakovsky would accomplish that proof on a calculator watch, but
  the following is my scheme function that enumerates numbers starting
  at 1 and stops when it finds a number that is expressable in two
  seperate ways by summing the cubes of two positive numbers. And it
  indeeds returns 1729.</p>
  
  <p>There are two areas where I would appreciate suggestions for
  improvement. One area is, being new to scheme, style and idiom. The other area is around the calculations. Sisc
  does not return exact numbers for roots, even when they could be. For
  example <code>(expt 27 1/3)</code> yields 2.9999999999999996. But I do get exact
  retults when cubing an exact number, <code>(expt 3 3)</code> yields <code>27</code>. My
  solution was to get the exact floor of a cube root and then test
  against the cube of the floor and the cube of the floor plus one,
  counting as a match if either match. This solution seems messy and hard to reason about. Is there a more straightforward way?</p>
  
  <pre><code>; Find the Hardy-Ramanujan number, which is the smallest positive
  ; integer that is the sum of the cubes of two positivie integers in
  ; two seperate ways.
  (define (hardy-ramanujan-number)
    (let ((how-many-sum-of-2-positive-cubes
            ; while i^3 + 1 &lt; n/1
            ;     tmp := exact_floor(cube-root(n - i^3))
            ;     if n = i^3 + tmp^3 or n = i^3 + (tmp + 1) ^3 then count := count + 1
            ; return count
            (lambda (n)
              (let ((cube (lambda (n) (expt n 3)))
                    (cube-root (lambda (n) (inexact-&gt;exact (expt n 1/3)))))
                (let iter ((i 1) (count 0)) 
                  (if (&gt; (+ (expt i 3) 1) (/ n 2))
                      count
                      (let* ((cube-i (cube i))
                             (tmp (floor (cube-root (- n cube-i)))))
                        (iter (+ i 1)
                          (+ count
                            (if (or (= n (+ cube-i (cube tmp)))
                                    (= n (+ cube-i (cube (+ tmp 1)))))
                                1
                                0))))))))))
      (let iter ((n 1))
        (if (= (how-many-sum-of-2-positive-cubes n) 2)
            n
            (iter (+ 1 n))))))
  </code></pre>