Padovan n-step number sequences

say 'Padovan N-step sequences; first 25 terms:';

for 2..8 -> \N {
    my @n-step = 1, 1, 1, { state $n = 2; @n-step[ ($n - N .. $n++ - 1).grep: * >= 0 ].sum } … *;
    put "N = {N} |" ~ @n-step[^25]».fmt: "%5d";
}

Output:

Padovan N-step sequences; first 25 terms:
N = 2 |    1     1     1     2     2     3     4     5     7     9    12    16    21    28    37    49    65    86   114   151   200   265   351   465   616
N = 3 |    1     1     1     2     3     4     6     9    13    19    28    41    60    88   129   189   277   406   595   872  1278  1873  2745  4023  5896
N = 4 |    1     1     1     2     3     5     7    11    17    26    40    61    94   144   221   339   520   798  1224  1878  2881  4420  6781 10403 15960
N = 5 |    1     1     1     2     3     5     8    12    19    30    47    74   116   182   286   449   705  1107  1738  2729  4285  6728 10564 16587 26044
N = 6 |    1     1     1     2     3     5     8    13    20    32    51    81   129   205   326   518   824  1310  2083  3312  5266  8373 13313 21168 33657
N = 7 |    1     1     1     2     3     5     8    13    21    33    53    85   136   218   349   559   895  1433  2295  3675  5885  9424 15091 24166 38698
N = 8 |    1     1     1     2     3     5     8    13    21    34    54    87   140   225   362   582   936  1505  2420  3891  6257 10061 16178 26014 41830

Last updated