RosettaCodeData/Task/Fusc-sequence/BASIC256/fusc-sequence.basic

33 lines
481 B
Plaintext

global f, max
max = 36000
dim f(max)
call fusc()
for i = 0 to 60
print f[i]; " ";
next i
print : print
print " Index Value"
d = 0
for i = 0 to max-1
if f[i] >= d then
print rjust(string(i),10," "), rjust(string(f[i]),10," ")
if d = 0 then d = 1
d *= 10
end if
next i
end
subroutine fusc()
f[0] = 0 : f[1] = 1
for n = 2 to max-1
if (n mod 2) then
f[n] = f[(n-1)/2] + f[(n+1)/2]
else
f[n] = f[n/2]
end if
next n
end subroutine