Great Common Divisor & Least Common Multiple(最大公约数和最小公倍数)

Function ZDGYS(ByVal m As Long, ByVal n As Long) As Long 'Great Common Divisor
ZDGYS = m
While n > 0
m = ZDGYS Mod n
ZDGYS = n
n = m
Wend
End Function


Function ZXGBS(ByVal m As Long, ByVal n As Long) As Long 'Least Common Multiple
ZXGBS= m * n / ZDGYS(m, n)
End Function

你可能感兴趣的:(com)