用VB编写求两个正整数的最小公倍数的过程
来源:百度知道 编辑:UC知道 时间:2024/04/28 02:21:09
Public Function GetDivisor(ByVal m As Long, ByVal n As Long) As Long
'辗转相除法求m/n的公约数
Dim t As Long
Do Until n = 0
t = m Mod n
m = n
n = t
Loop
GetDivisor = m
End Function
Public Function GetMultiple(ByVal m As Integer, ByVal n As Integer) As Integer
'求m/n的公倍数
GetMultiple = m * n / GetDivisor(m, n)
End Function