'Subject: Fibonacci numbers and the golden ratio phi.
'         A simple recurrent sequence, minimal module sample.
'Author : Sjoerd.J.Schaper
'Date   : 21-12-2003
'Code   : QuickBasic, PDS, VBdos
REM $LANG: "qb"
REM $INCLUDE: 'largeint.bi'
CONST p0 = 0, p1 = 1 '                 largeint pointers
n = LargeInit(p1, "fibonacc")
CLS : tim# = TIMER
LOCATE 1, 2: nx = 1221 '               set max.index

Letf p0, 0: Letf p1, 1
FOR n = 1 TO nx
   Add p0, p1: Swp p0, p1 '            F_n = F_n-2 + F_n-1
   g$ = "F" + LTRIM$(STR$(n)) + ": "
   Printn p0, g$, "", 2
NEXT n
n = INT(Bitl(p1) * .60206)
Printr p0, p1, "phi = ", n '           phi = F_n-1/ F_n

g$ = STR$(CSNG(TIMER - tim#))
Prints "Timer:" + g$ + " s", 1
CALL Term
SYSTEM

