Quality Testing

Quality is delighting customers

hi,

everyone how to write a script to generate Fibonacci series?

Views: 20855

### Replies to This Discussion

Hi Uma,

script for fibonacci series from 1 to 100

dim a, b, c
a=1
b=1
c=a+b
print a
print b
print c
while c<=100
print c
a=b
b=c
c=a+b
wend
hi, thanx for the ans

Fibonacci serious will work correctly if you assign the value like a=0,b=1 and also remove the print c before the while loop, then the output will display correct fibonacci series.

Thanks Vijay,

option explicit
Dim a, b, c, f1, f2, n
n = Cint (inputbox (" Enter the Number"))
a = 1      b = 1      c = 0
f1 = a & " , " & b
do while (c <= n)
c = a + b
if ( c > n ) then
exit do
end if
f2 = f2 & c & " , "
a = b  b = c
loop
msgbox f1 & " , " & f2
hi, thanx for the ans
Perhaps you could Google for "vbscript fibonacci series".  I found several examples that way.
hi, it was interview question

I recently stumbled across http://rindovincent.blogspot.com where there was a simple VBScript program to generate Fibonacci Series. I am pasting the same code from that blog with permission here.

<html>
<body>
<h2><center>
<script type="text/vbscript">
dim a,b,c
a=0
b=1
do while c<=21
document.write(b&"<br/>")
c=a+b
a=b
b=c
loop
</script>
</center></h2>
</body>
</html>

## Advertisement

© 2021   Created by Quality Testing.   Powered by