Fibonacci Series
Archiver
Posts: 46,084
Could anyone please help me figure out the PBASIC format for the
fibanacci series? (n1+n2=n3) (n2+n3=n4) etc. I am having trouble
programming this eqation into PBASIC.
Any help would be appreciated
-Jay
fibanacci series? (n1+n2=n3) (n2+n3=n4) etc. I am having trouble
programming this eqation into PBASIC.
Any help would be appreciated
-Jay
Comments
a Fibonacci series. But it may help anyway.
Klaus from Holland,
we just lost the semi finals of the European football championship, Portugal
won.
PS Fibonacci was about my first programming task when I was in university.
Punchcards, immense printing machines and a real IBM 370 for the entire
site. The world has changed al lot since then :-).
'{$STAMP BS2p}
'{$PBASIC 2.5}
n1 VAR Word
n2 VAR Word
n3 VAR Word
ix VAR Word
n1=1
n2=2
FOR ix=3 TO 20
n3=n2+n1
n1=n2
n2=n3
DEBUG DEC n3," "
PAUSE 250
NEXT
' standard Fibonacci Series generator
' 1,2,3,5,8,13,...,46368
' <per Tracy Allen>
x VAR Word
y VAR Word
z VAR Word
x=0
y=1
z=1
DO
debug ? z
x = y
y = z
z = x + y
LOOP UNTIL z<y
> Could anyone please help me figure out the PBASIC format for the
>fibanacci series? (n1+n2=n3) (n2+n3=n4) etc. I am having trouble
>programming this eqation into PBASIC.
>
>Any help would be appreciated
>
>-Jay
> ' {$PBASIC 2.5}
> ' standard Fibonacci Series generator
> ' 1,2,3,5,8,13,...,46368
> ' <per Tracy Allen>
> x VAR Word
> y VAR Word
> z VAR Word
>
> x=0
> y=1
> z=1
> DO
> debug ? z
> x = y
> y = z
> z = x + y
> LOOP UNTIL z<y
Tracy,
The simplicity of your code above made me realize I never heard
of Fibonacci. However, I am much more educated after reading the
following web site, which covers this topic in great details,
including origins from the year 1202!
http://library.thinkquest.org/27890/mainIndex.html
Thanks (To the originator of the topic) for expanding my knowledge!
Chris Savage
Knight Designs