Demonstrating Fibonacci sequence recursively : Recursive Function « Class Module « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Class Module » Recursive Function 
6.8.2.Demonstrating Fibonacci sequence recursively
Public Class Tester
   Public Shared Sub Main
      Dim number As Integer = 13

      Console.WriteLine("Fibonacci Value is " & Fibonacci(number))


   End Sub 
   ' calculate Fibonacci value recusively 
   Shared Function Fibonacci(ByVal number As IntegerAs Long

      ' check for base cases
      If number = OrElse number = Then
         Return number
      Else
         Return Fibonacci(number - 1+ Fibonacci(number - 2)
      End If

   End Function ' Fibonacci

End Class
Fibonacci Value is 233
6.8.Recursive Function
6.8.1.Recursively generates factorial of number
6.8.2.Demonstrating Fibonacci sequence recursively
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.