RosettaCodeData/Task/Padovan-n-step-number-sequences/Chipmunk-Basic/padovan-n-step-number-sequences.basic
2023-12-16 21:33:55 -08:00

29 lines
589 B
Text

100 CLS
110 t = 15
120 DIM p(t)
130 SUB padovann(n,p())
140 IF n < 2 OR t < 3 THEN
150 FOR i = 0 TO t-1
160 p(i) = 1
170 NEXT i
180 EXIT SUB
190 endif
200 padovann(n-1,p())
210 FOR i = n+1 TO t-1
220 p(i) = 0
230 FOR j = i-2 TO i-n-1 STEP -1
240 p(i) = p(i)+p(j)
250 NEXT j
260 NEXT i
270 EXIT SUB
280 END SUB
290 PRINT "First";t;" terms of the Padovan n-step number sequences:"
300 FOR n = 2 TO 8
310 PRINT n;":";
320 padovann(n,p())
330 FOR i = 0 TO t-1
340 PRINT USING "### ";p(i);
350 NEXT i
360 PRINT
370 NEXT n
380 END