PDA

View Full Version : سوال: ب م م و ک م م



ali-software
پنج شنبه 01 مرداد 1388, 09:38 صبح
لطفا اگه میشه یکم در باره به دست آوردن ب م م و ک م م در ویژوال بیسیک کمک کنید.ممنون

Mbt925
پنج شنبه 01 مرداد 1388, 11:39 صبح
بدست آوردن ب.م.م و ک.م.م به زبان ربطی نداره.




Function BMM(n1 As Integer, n2 As Integer) As Integer
Dim temp As Integer

Do While (n2 > 0)
temp = n1 Mod n2
n1 = n2
n2 = temp
Loop

BMM = n1
End Function

Function KMM(n1 As Integer, n2 As Integer) As Integer
KMM = n1 * n2
KMM = KMM / BMM(n1, n2)
End Function