<div><div>One definition of greatest common divisor in a ring R is:</div><div>  d is a greatest common divisor of x and y when:</div><div>       i)  d divides both x and y</div><div>      ii)  If e is a divisor of both x and y, then d divides e</div>
</div><div><br></div><div>Now let&#39;s consider the ring Q. Since Q is a field, 1 divides all elements.</div><div><br></div><div>This implies that 1 is a greatest common divisor of any non-zero x and y.</div><div>( ad i) 1 is a divisor of both x and y</div>
<div>  ad ii) 1 is a divisor of e )</div><div><br></div><div>It is therefore not obvious that gcd should be extendend as you suggest.</div><div>But maybe we can finde another name for the operation?</div><div><br></div><div>
/Jens Axel</div><div><br></div><br><div class="gmail_quote">2011/12/7 David Van Horn <span dir="ltr">&lt;<a href="mailto:dvanhorn@ccs.neu.edu">dvanhorn@ccs.neu.edu</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
It would be nice if gcd and lcm were extended to rational numbers, which seems in-line with Scheme&#39;s philosophy (but not standards) on numbers.<br>
<br>
(define (gcd-rational . rs)<br>
  (/ (apply gcd (map numerator rs))<br>
     (apply lcm (map denominator rs))))<br>
<br>
(define (lcm-rational . rs)<br>
  (/ (abs (apply * rs))<br>
     (apply gcd-rational rs)))<br>
<br>
David<br>
______________________________<u></u>___________________<br>
 For list-related administrative tasks:<br>
 <a href="http://lists.racket-lang.org/listinfo/dev" target="_blank">http://lists.racket-lang.org/<u></u>listinfo/dev</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>-- <br>Jens Axel Søgaard<br><br><br>