The comments were intended to extend the preceding prose explanation rather than being comments per se. The actual code is not much longer than the naive version, though, so if I get around to writing an updated version, I'd probably find some other method of conveying that info.
Some other things I'd do differently if I were to update it today:
- I'd write it in Javascript and provide a little interactive applet to play with it. (Similar to my posts on primality testing: http://www.akalin.cx/intro-primality-testing and http://www.akalin.cx/primality-testing-polynomial-time-part-... .)
- I'd upload the code to GitHub.
- I'd add unit tests.
Cheers!
Your links on primality testing are particularly relevant to me as I just finished that section in SICP - thanks for the links!