Hi, I was trying to write an alogorithm so it could find the GCF(Greatest Common Factor) of two numbers, and someone gave me a function along with some other code. but my question is how this function works, if anyone could explain it step by step what is doing that would be great.

VB.NET:

Public Function GCD(a As Integer, b As Integer)
If b Then
GCD = GCD(b, a Mod b)
Else
GCD = a
End If
End Function

This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.