Fibonacci numbers


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.