1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
INTEGER FUNCTION ILCM( M, N )
*
* -- ScaLAPACK tools routine (version 1.5) --
* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
* and University of California, Berkeley.
* May 1, 1997
*
* .. Scalar Arguments ..
INTEGER M, N
* ..
*
* Purpose
* =======
*
* ILCM computes and returns the Least Common Multiple (LCM) of two
* positive integers M and N. In fact the routine computes the greatest
* common divisor (GCD) and use the fact that M*N = GCD*LCM.
*
* Arguments
* =========
*
* M (input) INTEGER
* On entry, M >=0. Unchanged on exit.
*
* N (input) INTEGER
* On entry, N >=0. Unchanged on exit.
*
* =====================================================================
*
* .. Local Scalars ..
INTEGER IA, IQ, IR
* ..
* .. Executable Statements ..
*
IF( M.GE.N ) THEN
IA = M
ILCM = N
ELSE
IA = N
ILCM = M
ENDIF
*
10 CONTINUE
IQ = IA / ILCM
IR = IA - IQ * ILCM
IF( IR.EQ.0 ) THEN
ILCM = ( M * N ) / ILCM
RETURN
END IF
IA = ILCM
ILCM = IR
GO TO 10
*
* End of ILCM
*
END
|