Thursday, April 15, 2010

Fibonacci Series Code

Click on Back to the Assignment Question Page

Write a script to generate the Fibonacci Series. Again ask the user for the limit.


In order to generate a Fibonacci Series in VB Script we make use of the DO WHILE LOOP Looping Construct.


The code for generating the Fibonacci Series is given below.

n = CINT(Inputbox("Enter a range"))
f1=0
f2=1
f3=f1+f2
var= f1& ", " &f2
do while f3 < n
var = var& ", "&f3
f1=f2
f2=f3
f3=f1+f2
loop

MsgBox "Fibonacii Series for the limit " &n&" is: " &var



Till the condition is satisfied the inner conditions get executed and stored in the var variable thus giving out the output as 0,1,1,3,5,8,13,21,34,55 and 89 if we take the range as 100.

Click on Back to the Assignment Question Page

2 comments:

Unknown said...

Can you write algorithm for the above Fibonacci Series script.

Unknown said...

How to write code for negative & decimal fibanocci series

Post a Comment