Public Function gcd(m As Integer, n As Integer) As Integer If (m Mod n) = 0 Then gcd = n Else gcd = gcd(n, m Mod n) End If End Function