36 lines
508 B
Text
36 lines
508 B
Text
global t
|
|
t = 15
|
|
global p
|
|
dim p(t)
|
|
|
|
print "First"; t; " terms of the Padovan n-step number sequences:"
|
|
for n = 2 to 8
|
|
print n; ":";
|
|
|
|
call padovanN(n, p)
|
|
|
|
for i = 0 to t-1
|
|
print rjust(p[i],4);
|
|
next i
|
|
print
|
|
next n
|
|
end
|
|
|
|
subroutine padovanN(n, p)
|
|
if n < 2 or t < 3 then
|
|
for i = 0 to t-1
|
|
p[i] = 1
|
|
next i
|
|
return
|
|
end if
|
|
|
|
call 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[j]
|
|
next j
|
|
next i
|
|
return
|
|
end subroutine
|