Function fib(ByVal x As Integer)
If x = 1 Or x = 2 Then
Return 1
Else
Return fib(x - 1) + fib(x - 2)
End If
End Function
Sub Main()
Dim i, n As Integer
While (1)
Console.Write("費式序列個數 :")
n = Console.ReadLine()
If n = 0 Then
Exit While
End If
For i = 1 To n
Console.WriteLine("第({0})項 : {1}", i, fib(i))
Next
Console.WriteLine("按Enter鍵繼續!")
Console.ReadLine()
End While
End Sub