Least Common Multiple

This algorithm find the least common multiple of two integers.



									Private Shared Function GCD(a As Integer, b As Integer) As Integer
	If a = 0 Then
		Return b
	End If

	While b <> 0
		If a > b Then
			a -= b
		Else
			b -= a
		End If
	End While

	Return a
End Function

Public Shared Function LCM(a As Integer, b As Integer) As Integer
	Return (a * b) \ GCD(a, b)
End Function
								


Example

									Dim _LCM = LCM(15, 12)
								


Output

									60