Posted By

indra on 10/29/10


Tagged

algorithm


Versions (?)

Fibonacci numbers


 / Published in: VB.NET
 

URL: http://en.literateprograms.org/Fibonacci_numbers_%28Visual_Basic_.NET%29#chunk%20def:fib

  1. Imports System.Console
  2.  
  3. Module Fibonacci
  4. Function fib(ByVal n)
  5. If n < 2 Then Return n Else Return fib(n - 1) + fib(n - 2)
  6. End Function
  7.  
  8. Sub Main()
  9. Dim n As Integer
  10. For n = 1 To 30
  11. WriteLine(n & ":" & fib(n))
  12. Next
  13. End Sub
  14. End Module

Report this snippet  

You need to login to post a comment.