VBScript implementation of Fibonacci series using array
kw.vbs
Dim arr(30)
arr(0)=0
arr(1)=1
n=inputbox("How Many Elements You Want To Display")
For i = 2 To n
    arr(i)=arr(i-1)+arr(i-2)
Next

For i = 0 To n
    print arr(i)
Next
Output
0
1
1
2
3
5
8
13
21
34
55
VBScript implementation of Fibonacci series using recursion
kw.vbs
Function Fibonacci(n)
    If (n < 2) Then
        Fibonacci = n
    Else
        Fibonacci = Fibonacci(n-1) + Fibonacci(n-2)
    End If
End Function

For i = 0 To 10
    F = Fibonacci(i)
    print F
Next
Output
0
1
1
2
3
5
8
13
21
34
55
Advertisement