Function Recursive : Function Recursive « Language Basics « VB.Net






Function Recursive

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

1.Display directories on your drive recursivelyDisplay directories on your drive recursively
2.Calculating factorials using recursionCalculating factorials using recursion
3.Recursive Function DemoRecursive Function Demo