Fibonacci in Basic

It is a pattern when you add the 2 previous numbers together and to get the next number. And so on.

1. 1. 1. 2. 3. 5. 8. 13. 21. 34. 55. 89. 144. And so on.
BASIC
fib0=0

fib1=1

FOR cnt= 1 TO n

fib2=fib1+fib0

PRINT fib2

fib0=fib1

fib1=fib2

NEXT cnt


/* fib2 is the sum of the two preceeding terms.*/

0 comments:

Post a Comment