computer science

Two Stanzas on Euclid's GCD

Here’s an double tanka on Euclid’s algorithm (for finding the greatest common divisor of two numbers), executable as a Scheme program. My notes indicate that I wrote it during a tedious teleconference.

(define gcd
 (lambda (m n) (if (zero?
  n) m (gcd
   n (remainder m n))))) ; Look!
    ; Falling leaves unveil the tree.

      ; Two integers stand.
       ; They divide, m's ghost remains.
        ; As autumn passes,
         ; n succeeds m, floating down.
          ; Zero reveals the great truth.

2 replies on “Two Stanzas on Euclid's GCD”

I love the idea of a ‘batch fugue’! In fact, that’s more or less how the fugal exposition is constructed: call theme1.bat in the first voice; when it finishes, call theme1.bat in the second voice and cntrthem.bat in the first . . . .

Leave a Reply to paul Cancel reply

Your email address will not be published. Required fields are marked *