Friday, November 19, 2010

VBScript Code - Fibonacci series

Write the below code in a notepad and save it as a .vbs file. Either run it from command prompt or run it by double-clicking on it.

VBScript Code - Fibonacci series

Function fibonacci(n)
Dim arr:redim arr(n)
arr(0)=1
arr(1)=1
for i=2 to n
  arr(i)=arr(i-1)+arr(i-2)
next
fibonacci = arr
end function

myarr=fibonacci(12)

for i =0 to ubound(myarr)-1
msgbox myarr(i)
next