<div dir="ltr">The following code runs in reasonable time (about 5s) on 64-bit 5.3.4, but takes about 20x as long on 32-bit. I adapted this code from some scheme code on the PE forum. Thoughts?<div><br></div><div>Thanks,</div>
<div>-Joe<br><div><br></div><div><div>(define (euler210)</div><div> (define limit (expt 10 8))</div><div> (define ldiv4 (quotient limit 4))</div><div> (define ldiv8 (quotient limit 8))</div><div> (define ldiv8xrad2 (inexact->exact (floor (* ldiv8 (sqrt 2)))))</div>
<div> (define sqrldiv8x2 (* ldiv8 ldiv8 2))</div><div> (+ </div><div> (* 3 (* limit (/ limit 2))) ; rectangular regions</div><div> (- (* ldiv4 (add1 ldiv4)) 2)</div><div> (* 8 </div><div> (let loop ([x (add1 ldiv8)] [sum 0]) ; 1/8 of circle points (outside of inner square)</div>
<div> (if (< ldiv8xrad2 x) sum</div><div> (let* ([y (sqrt (- sqrldiv8x2 (* x x)))] [ymax (inexact->exact (floor (if (integer? y) (- y 1) y)))])</div><div> (loop (add1 x) (+ sum ymax))))))</div>
<div> (* 4 (- ldiv8xrad2 ldiv8))))</div></div></div></div>