RosettaCodeData/Task/Fibonacci-sequence/BASIC/fibonacci-sequence-1.basic

25 lines
488 B
Plaintext

# Basic-256 ver 1.1.4
# iterative Fibonacci sequence
# Matches sequence A000045 in the OEIS, https://oeis.org/A000045/list
# Return the Nth Fibonacci number
input "N = ",f
limit = 500 # set upper limit - can be changed, removed
f = int(f)
if f > limit then f = limit
a = 0 : b = 1 : c = 0 : n = 0 # initial values
while n < f
print n + chr(9) + c # chr(9) = tab
a = b
b = c
c = a + b
n += 1
end while
print " "
print n + chr(9) + c