Padovan n-step number sequences: Difference between revisions
Added Just Basic
(Added various BASIC dialects (BASIC256, Chipmunk Basic, QBasic, Pure BASIC and Yabasic) Moved FreeBASIC to section BASIC) |
(Added Just Basic) |
||
Line 658:
7: 1 1 1 2 3 5 8 13 21 33 53 85 136 218 349
8: 1 1 1 2 3 5 8 13 21 34 54 87 140 225 362</pre>
==={{header|Just BASIC}}===
{{trans|FreeBASIC}}
{{works with|Liberty BASIC}}
<syntaxhighlight lang="vb">global t, p
t = 15
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 using("####", p(i));
next i
print
next n
end
sub padovanN n, p
if n < 2 or t < 3 then
for i = 0 to t-1
p(i) = 1
next i
exit sub
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(i) + p(j)
next j
next i
end sub</syntaxhighlight>
==={{header|QBasic}}===
|