CLEAR ALL
? "Fibonacci squence using fibers"
?
? "Press any key to generate the next number in the Fibonacci sequence, or Esc to quit."
?
START fib()
DO
    INK RND.COLOR
    ? fib()
    GETKEY a$
LOOP UNTIL a$=CHR$(27) OR FIBER.ISDONE(fib())
END
FIBER fib()
    prev=1
    curr=1
    YIELD RETURN prev
    YIELD RETURN curr
    WHILE TRUE
        ' Generate the next number in the sequence
        temp=curr
        curr=curr+prev
        prev=temp
        YIELD RETURN curr
    WEND
END FIBER
