home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / compiler / ubasic / malm / fcgcd.ub < prev    next >
Text File  |  1990-08-22  |  391b  |  13 lines

  1.    10   *Fcgcd(A,B,&C,&Ca)
  2.    20   ' Gcd with one coefficient.  c is the gcd of a and b.
  3.    30   ' ca*a + cb*b = c for some cb    16 April 1990
  4.    40   local R,Q,T,Af,Bf,B1
  5.    50   Ca=1:B1=0:Af=A:Bf=B
  6.    60   while B
  7.    70   T=B:Q=A\B:B=res
  8.    80   R=Ca-Q*B1:Ca=B1:B1=R:A=T
  9.   100   wend
  10.   110   C=A
  11.   160   if C<0 then neg C:neg Ca endif
  12.   170   return:' End of procedure Fcgcd.
  13.