Function Recursive
Imports System
Public Class MainClass
Shared Sub Main()
Console.WriteLine("The GCD of 36 and 99 is " & GCD(36, 99))
End Sub
Shared Function GCD(ByVal p As Long, ByVal q As Long) As Long
If Q Mod P = 0 Then
Return P
Else
Return GCD(Q, P Mod Q)
End If
End Function
End Class
Related examples in the same category