home *** CD-ROM | disk | FTP | other *** search
/ Learn Java Now / Learn_Java_Now_Microsoft_1996.iso / MsDev / Samples / Microsoft / COMCallingJava / euclid.java < prev    next >
Encoding:
Java Source  |  1996-08-27  |  390 b   |  32 lines

  1. /*
  2.  *
  3.  * CEuclid
  4.  *
  5.  */
  6.  
  7. // import the COM interface
  8. import euclid.*;
  9.  
  10. // Java class implements the COM interface
  11. class CEuclid implements IGCD
  12. {
  13.     // public method to compute 
  14.     // greatest common denominator (GCD)
  15.     public int GCD(int u, int v)
  16.     {
  17.         int t;
  18.         while (u > 0)
  19.         {
  20.             if (u < v)
  21.             {
  22.                 t=u;
  23.                 u=v;
  24.                 v=t;
  25.             }
  26.             u=u-v;
  27.         }
  28.         return v;
  29.     }
  30. }
  31.  
  32.