From: "Hans van Kruijssen" Subject: Re: Least Common Denominator Date: 15 Mar 2000 00:00:00 GMT Message-ID: <38cfc6c9@dnews> References: <8acluk$jkn6@bornews.borland.com> <38ced08d@dnews> <38ced7fc@dnews> X-Trace: 15 Mar 2000 09:22:17 -0800, 212.64.56.26 X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: borland.public.codecentral X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Hi, "John Kaster (Borland)" wrote in message news:38ced7fc@dnews... > Another good candidate for CodeCentral submission. I submitted the following code snippet to codecentral (id 14560) function GCD( Nr1, Nr2: integer ): integer; {Calculate the greatest common divisor using the algorithm of Euclides} var Temp: integer; begin while Nr2 <> 0 do begin Temp := Nr2; Nr2 := Nr1 mod Temp; Nr1 := Temp; end; Result := Nr1; end; function LCD( Nr1, Nr2: integer ): integer; {Calculate the Least common dominator} begin Result := (Nr1 * Nr2) div GCD( Nr1, Nr2 ); end; The test for Nr2 <> 0 makes the routine quite a bit faster :) Greetings, Hans.