36 lines
557 B
Text
36 lines
557 B
Text
t = 15
|
|
dim p(t)
|
|
|
|
print "First", t, " terms of the Padovan n-step number sequences:"
|
|
for n = 2 to 8
|
|
print n, ":";
|
|
|
|
padovanN(n, p())
|
|
|
|
for i = 0 to t-1
|
|
print p(i) using ("###");
|
|
next i
|
|
print
|
|
next n
|
|
end
|
|
|
|
sub padovanN(n, p())
|
|
local i, j
|
|
|
|
if n < 2 or t < 3 then
|
|
for i = 0 to t-1
|
|
p(i) = 1
|
|
next i
|
|
return
|
|
fi
|
|
|
|
padovanN(n-1, p())
|
|
|
|
for i = n + 1 to t-1
|
|
p(i) = 0
|
|
for j = i - 2 to i-n-1 step -1
|
|
p(i) = p(i) + p(j)
|
|
next j
|
|
next i
|
|
return
|
|
end sub
|